![]() |
|
||||||
|
"exact phrase" include -exclude
will give you more specific results |
What is PHP? Introduction to PHP.by Alex Plumpton
What is PHP?
PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual. Have you ever wanted to have dynamic pages, move data more powerfully, or make maintenance easier? Well, a great solution is PHP PHP is a recursive acronym for Hypertext PreProcessor. It is a general-purpose scripting language for use on the Internet and it can be embedded into HTML. PHP is a server-side scripting language. This means that the scripts on the page are parsed by the server before they reach the browser. Therefore, if you view the source of the page, you won't see the PHP code. Average users won't even know you are using it, and it is imposssible to steal your code unless a person has direct access to the server. Getting ready to use PHP Because PHP is a server-side language, you must have a host that supports it in order to use it. Most hosts support PHP. However, you can run your own local Web server on your computer to test and learn PHP. You simply download a free Web server, such as Apache or Xitami and follow their instructions for setup. You also need to download the PHP package for your operating system. I also suggest you download the PHP reference documentation. It will come in very handy. After installing PHP and a Web server, you are ready to make your first program. Writing PHP Code PHP code is inserted directly into your HTML page at any place. PHP code goes between these tags: <?php ?> A simple page would look like this: <html> <body> <?php echo('<h1>Hello World</h1>'); ?> </body> </html> To try this out, open Notepad, or any simple text editor. Do NOT try to use Word or anything similar as it will try to convert your code. Then save the file with a .php extension. Note that this isn't an executable file. It acts as a regular HTML file, except the Web server is set to parse the PHP code. You can view this file by turning on your server, and placing the file in the root directory. Then type http://localhost/ into a browser and navigate to the file. This script simply prints the words Hello World at heading 1 size on the page. You wouldn't need PHP to do this, it is just an example. Note how HTML tags can be placed in the echo. Variables The previous code can also be written using variables. Variables, like it algebra are a letter or word (that can contain numbers) that represents something else. The previous code can be written like this. <html> <body> <?php $a = '<h1>Hello World</h1>'; echo($a); ?> </body> </html> This puts out text in a variable and prints the variable. Variables can also be added, subtracted, multiplied, and divided. <html> <body> <?php $a = 2; $b = 10; $c = 5; echo($a * $b / $c); ?> </body> </html> The above prints out 4 (2 times 10 divided by 5). Easy Maintenance With PHP Regular site maintenance can be a pain if you have to change even one link on every page. PHP can make these types of situations much easier by allowing you to edit one file and change multiple pages. This is done through the use of includes. An include brings one page into another page. For example, say we have this basic page: <html> <body> <div id="nav"> <a href="link1.html">Link 1</a><br> <a href="link2.html">Link 2</a><br> <a href="link3.html">Link 3</a> </div> <div id="content"> Content here... </div> </body> </html> To make maintenance easier, we could include the navigation into every page. To do this we put the nav in a separate .php file. <div id="nav"> <a href="link1.html">Link 1</a><br> <a href="link2.html">Link 2</a><br> <a href="link3.html">Link 3</a> </div> Then we'll name this nav.php. Then we replace the nav in the our basic page with a PHP include statement. <html> <body> <?php include('nav.php'); ?> <div id="content"> Content here... </div> </body> </html> Now the nav.php file is substituted for the include statement by the server. If you view the source, the page will look normal, because the server brings in the nav.php before it ever reaches the browser. Now simply add that statement in place of the nav on every page, and you only have to edit the nav.php to change the nav on every page. This is a wonderful time saver. And now you are off to a great start to utilizing PHP on your own site. With this article ONLINEHOWTO.net represents only personal opinion of the author and don't targets advertising or discriminating some product.
Other Articles:
|
RECOMENDED TUTORIALS
Need a specific tutorial? Do not hesitate and submit a request! |
|||||
| Keywords: remote desktop port change remote desktop port rdp port number remote desktop port number RDP port function overloading in c++ change RDP port exception handling in C++ rdp ports remote desktop ports function overloading Trillian webcam remote desktop port change windows remote desktop port remote desktop change port exception handling c++ how to change remote desktop port change remote desktop port number function overloading c++ check my windows version | |||||||
|
C++ |
Windows |
Video editing |
Vector Graphics |
Linux |
Players |
Multimedia |
FTP Clients |
Plesk Control Panel
Home | Articles | Sitemap | Terms & Privacy © ONLINEHOWTO.net 2006 - 2008 |
|||||||