Monday, January 7, 2008

Useful Notes in php

To open a block of PHP code in a page you can use one of these four sets of opening and closing tags

Opening Tag Closing Tag


<% %>


The first pair () is called short tags. You should avoid using short tags in your application especially if it's meant to be distributed on other servers. This is because short tags are not always supported ( though I never seen any web host that don't support it ). Short tags are only available only explicitly enabled setting the short_open_tag value to On in the PHP configuration file php.ini.

So, for all PHP code in this website I will use the second pair, .

Now, for the first example create a file named hello.php ( you can use NotePad or your favorite text editor ) and put it in your web servers root directory. If you use Apache the root directory is APACHE_INSTALL_DIR\htdocs, with APACHE_INSTALL_DIR is the directory where you install Apache. So if you install Apache on C:\Program Files\Apache Group\Apache2\htdocs then you put hello.php in C:\Program Files\Apache Group\Apache2\htdocs





echo "

Hello World, How Are You Today?

";
?>

No comments: