Syntax andVariablesIn this chapter, we (Web hosting ratings) cover the basic
Syntax andVariablesIn this chapter, we cover the basic syntax of PHP the rules that allwell-formed PHP code must follow. We explain how to use variablesto store and retrieve information as your PHP code executes and thetype system that governs what kinds of values can be stored in thefirst place. Finally, we look at the simplest ways to display text thatwill show up in your user s browser window. PHP Is ForgivingThe first and most important thing to say about the PHP language isthat it tries to be as forgiving as possible. Programming languagesvary quite a bit in terms of how stringently syntax is enforced. Pickiness can be a goodthing because it helps make sure that thecode you re writing is really what you mean. If you are writing a pro- gram to control a nuclear reactor and you forget to assign a variable, it is far better to have the program be rejected than to create behav- ior different from what you intended. PHP s design philosophy, how- ever, is at the other end of the spectrum. Because PHP started life asa handy utility for making quick-and-dirty Web pages, it emphasizesconvenience for the programmer over correctness; rather than havea programmer do the extra work of redundantly specifying what ismeant by a piece of code, PHP requires the minimum and then triesits best to figure out what was meant. Among other things, thismeans that certain syntactical features that show up in other lan- guages, such as variable declarations and function prototypes, aresimply not necessary. With that said, though, PHP can t read your mind; it has a minimumset of syntactical rules that your code must follow. Whenever you seethe words parseerrorin your browser window instead of the coolWeb page you thought you had just written, it means that you ve bro- ken these rules to the point that PHP has given up on your page. HTML Is Not PHPThe second most important thing to understand about PHP syntax isthat it applies only within PHP. Because PHP is embedded in HTMLdocuments, every part of such a document is interpreted as eitherPHP or HTML, depending on whether that section of the document isenclosed in PHP tags. 55CHAPTER …In This ChapterUnderstanding the basicrules of PHPStoring information variables, and data typesOutput to HTML …
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision make web site services