1 / 11

Introduction to PHP

Introduction to PHP. Lesson 3. PHP is the most popular web development language in the world. PHP sources of Information http://php.net http://www.zend.com http://www.hostscripts.com PHP: Hypertext Preprocessor PHP dealt with before HTML Lies between web server and HTML

andra
Download Presentation

Introduction to PHP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to PHP Lesson 3

  2. PHP is the most popular web development language in the world • PHP sources of Information • http://php.net • http://www.zend.com • http://www.hostscripts.com • PHP: Hypertext Preprocessor • PHP dealt with before HTML • Lies between web server and HTML • Interpreted language (i.e. not compiled) • Code is interpreted on the fly • Code is in plain text, so anyone with access to the web serves can view it • However, code can still be encrypted so it can’t be stolen. Sites that offer facilities for encryption include http://www.zend.com and IOnQ

  3. PHP Programming standards • Goal is to make code easy to read and understand • However, there is NO accepted industry coding standards • Each programmer is encouraged to come up with his own standard or if he’s a part of a company and the company has its own standard then he is required to follow that standard.

  4. Use Comments • Use comments but don’t comment everything because that would required a huge amount of time. // # /* .. */ Single line comment Multi- Line comment • Better if just make the code readable and simple • Also, use indentation

  5. Embed PHP within HTML • If you need to create a page with few dynamic elements • Embed HTML with PHP • If you need to create a long complex PHP script

  6. PHP Opening and Closing Tags • <?php….?> - this setting is always acceptable in any PHP configuration • <? …?> - this short_tag setting may not be available depending on your PHP config file (php.ini); make sure that in php.ini there is a line short_tag= on • <script language=“php”>…</script> - html style tag • <% … %> - ASP style tag

  7. NOTE: • Each HTML browser may interpret some HTML tags in a different way. By embedding HTML within PHP you are assured that HTML will be interpreted in only 1 way. • However, if there is a need to change code and the programmer who will do it is not familiar with PHP then that would be a problem. So separate those parts that can be separated from PHP. • Ex. <html><head> tags…</body></html> • Note also that every PHP statement ends in a semi-colon (;)

  8. Sample1 PHP program <html><body>// save as hello.php in your htdocs folder <?phpecho "Hello World!"; //you can also use print ?></body></html>

  9. Sample2 PHP program <html><body>//save this as info.php in your htdocs folder<?phpphpinfo();?></body></html>

  10. phpinfo() • is a php function that outputs information about your PHP settings: • Tells you the PHP version installed • Status of PHP Core variables • Note that there are local and Mastery Values. • The local value can be set on a page-by-page basis, by .htaccess file, or by a domain configuration. • The master value is the global setting as specified in the php.ini (of which only the System Administrators have access)

  11. PHP Exercise 1: • Fix the errors in the PHP script (erroneous.php) open the link. Save you solution as my_solution_SURNAME.php erroneous.php

More Related