I l @ ve RuBoard |
Now that you have created your first PHP script, it's time to make it actually do something. As discussed in the introduction, PHP tells the server what data to send to your Web browser. For starters, you will use the phpinfo() function to create our data. This function, when called, will send a table of information to the Web browser itemizing the specifics of the PHP installation on that particular server. To add the phpinfo() function to your script:
Every statement within PHP code must end with a semicolon (;). Forgetting to do so is a common cause of errors. You can put multiple statements on one line, with each separated by its own semicolon. For the sake of clarity, however, I would not recommend it. A statement in PHP is an executable line of code, like print() or phpinfo(). The semicolon concluding these lines are the equivalent of telling PHP to go ahead and execute the command. Conversely, comment lines, the PHP tags, control structures (conditionals, loops , etc.), and certain other constructs I'll discuss in this book do not merit a semicolon. Each of these aspects of PHP do not do anything in and of themselves so much as dictate the circumstances for the statements to follow. That is to say: the PHP tag only indicates that PHP code is to follow; comment characters render text moot, and so forth. Thus, in general, a semicolon concludes a specific action, while no semicolon is required for constructs that create conditions. Tip For better or worse , PHP is rather liberal when it comes to case sensitivity of built-in functions like PHPINFO(). PHPinfo() and PHPINFO() will net the same results. Later in the book (for example, Chapter 2, Variables) you will see examples of instances where the word case will make a crucial difference. HTML, in contrast, is entirely case insensitive. Tip Phpinfo() is an example of a built-in function which comes standard in PHP. To learn more about functions and how to create your own, see Chapter 9, Creating Functions. Tip You will find it handy to have a copy of the test.php file around. You can use this to check the PHP capabilities of a new server or see what features are supported, such as databases, GIF building, etc. You can also use this file to experiment with different extensions and learn which ones the server will process correctly and which it will not. |
I l @ ve RuBoard |