1 / 114

-By V.Gouthaman

-By V.Gouthaman. INTRODUCTION.

malha
Télécharger la présentation

-By V.Gouthaman

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. -By V.Gouthaman

  2. INTRODUCTION PHP: Hypertext Preprocessor is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document. As a general-purpose programming language, PHP code is processed by an interpreter application in command-line mode performing desired operating system operations and producing program output on its standard output channel.

  3. It may also function as a graphical application. PHP is available as a processor for most modern web servers and as standalone interpreter on most operating systems and computing platforms.PHP was originally created by Rasmus Lerdorf in 1995 and has been in continuous development ever since. The main implementation of PHP is now produced by The PHP Group and serves as the de facto standard for PHP as there is no formal specification. PHP is free software released under the PHP License.

  4. INSTALLATIONANDCONFIGURATION

  5. Step 1: Download the latest Windows PHP Binaries (MSI file) from “http://www.php.net/get/php-5.2.4-win32-installer.msi/from/a/mirror” . I choose the eZNetworking mirror because it is the closest one to Malaysia. Choose a mirror that is nearer to your country for a faster file download. The latest PHP version that I downloaded is 5.2.4. Save the file to your Desktop. Step 2: Right click on the file and click “Install“.

  6. Step 3: Click “Next ” once the Welcome page is displayed.

  7. Step 4: Select “I accept the license agreement” and click “Next “.

  8. Step 5: Change your PHP installation path OR just accept the default path - C:\Program Files\PHP\ and click “Next “.

  9. Step 6: On the Web Server Setup screen, select the Apache 2.2.x Module and click “Next “.select-webserver-to-install-php-on-apache-2

  10. Step 7: On the Apache Configuration Directory screen, browse for the Apache configuration directory (conf) OR just enter C:\Program Files\Apache Software Foundation\Apache2.2\conf\ and click “Next ” to proceed with the installation.

  11. Step 8: For now, accept the default selection and click “Next”.

  12. Step 9: Click “Install ” to install PHP 5 on Windows.

  13. Step 10: Click “Finish ” once completed. PHP 5 is successfully installed.

  14. Step 11: Start your Apache 2.2 server using the “Monitor Apache Servers” console (Start -> Apache HTTP Servers 2.2.4 -> Monitor Apache Servers ). You can see that PHP was successfully installed by checking the Apache status at the bottom of the console.

  15. Testing PHP 5 Installation Step 1: Open up your Windows Notepad. Type in “<?php phpinfo(); ?>” inside the file. Save this file as “info.php” inside your Apache root directory, C:\Program Files\Apache Software Foundation\Apache2.2\htdocs .

  16. Step 2: Open up your web browser. In the address bar, type in your web server domain name plus info.php as the file name.Example: http://www.syahid.com/info.php . You should get a PHP configuration page just like the one below. Congratulations! You have successfully installed and test PHP 5 on Windows!

  17. CONFIGURATION

  18. Configure PHP 5 to Work with MySQL with MySQL PHP Extension Previously, we have installed PHP with minimal modules / extension. To add MySQL support to PHP, you need to change your PHP installation - by adding the MySQL extension on top of your PHP installation. Please make sure that your original PHP 5 MSI installer still remains at its original place .

  19. Step 1: Open the Add / Remove Programs console via Windows Control Panel. Find the PHP 5.x.x entry and click “Change “.

  20. Step 2: Click “Next ” once you are prompted the Welcome page.

  21. Step 3: Click the “Change ” button to proceed.

  22. Step 4: Select Apache 2.2.x as shown in the picture below. Click “Next ” once again.

  23. Step 5: Select your Apache configuration directory (conf) - the directory where your httpd.conf resides. Click “Next ” once done.

  24. Step 6: On the “Choose items to install” screen, click on the plus (+) icon next to Extensions to expand the list. click-plus-button-to-expand-extensions-part

  25. Step 7: Select on the “X” next to “MySQL” and select “Entire feature will be installed on local hard drive”. Click “Next” again

  26. Step 8: Click the “Change” button to save all the PHP configuration changes.

  27. Step 9: Finally, restart your Apache 2.2 web server! You can check out that the MySQL extension support for PHP was successfully installed by checking out the info.php / index.php page that was created before.

  28. PHP SAMPLE PROGRAMS

  29. Sample 1: current date in an HTML page <html> <head> <title>Example #1 TDavid's Very First PHP Script ever!</title> </head> <? print(Date("l F d, Y")); ?> <body> </body> </html>

  30. 2.current month/day/date format <html> <head> <title>Example #3 TDavid's Very First PHP Script ever!</title> </head> <? print(Date("m/j/y")); ?> <body> </body> </html>

  31. 3. current month/day/date with HTML colors & formatting <html> <head> <title>PHP Script examples!</title> </head> <font face="Arial" color="#FF00FF"><strong><? print(Date("m/j/y")); ?> </strong></font> <body> </body> </html>

  32. 4. change background color based on day of the week using if else elseif statements <html> <head> <title>Background Colors change based on the day of the week</title> </head> <? $today = date("l"); print("$today"); if($today == "Sunday") { $bgcolor = "#FEF0C5"; }

  33. elseif($today == "Monday") { $bgcolor = "#FFFFFF"; } elseif($today == "Tuesday") { $bgcolor = "#FBFFC4"; } elseif($today == "Wednesday") { $bgcolor = "#FFE0DD"; } elseif($today == "Thursday"){ $bgcolor = "#E6EDFF";}

  34. elseif($today == "Friday") { $bgcolor = "#E9FFE6"; } else { // Since it is not any of the days above it must be Saturday $bgcolor = "#F0F4F1"; } print("<body bgcolor=\"$bgcolor\">\n"); ?> <br>This just changes the color of the screen based on the day of the week </body> </html>

  35. <html> <head> <title>Background Colors change based on the day of the week</title></head> <?$today = date("w"); $bgcolor = array( "#FEF0C5", "#FFFFFF", "#FBFFC4", "#FFE0DD", "#E6EDFF", "#E9FFE6", "#F0F4F1" ); ?> <body bgcolor="<?print("$bgcolor[$today]");?>"> <br>This just changes the color of the screen based on the day of the week </body> </html>

  36. 5. Add date time stamp "page last updated on.." using filemtime function using forms, cookies, flat file databases, random number generation <html> <head> <title>Page last updated on month/date/year hour:min PHP Script</title> </head> <? $last_modified = filemtime("example7.php3"); print("Last Modified "); print(date("m/j/y h:i", $last_modified)); ?> </body> </html>

  37. 6. Setting and retrieving a cookie <? $check = "test"; $check .= $filename; if ($test == $check) {print("<HTML><BODY>You have already voted. Thank you.</BODY></HTML>"); } else{ $rated = "test"; $rated .= $filename; setcookie(test, $rated, time()+86400); print("<HTML><BODY><br>You haven't voted before so I recorded your vote</BODY></HTML>"); } ?>

  38. 7. Getting an average number using PHP <? $total_ratings = (3+2+3+1+5+2+3); $total_votes = 7; $average = $total_ratings / $total_votes; print("The Average Rating Is: $average"); ?>

  39. 8. showing the surfer average vote statistics, using printf function <? $path = "/YOUR/PATH/TO/public_html/php_diary/data"; $filename = "122499.dat"; $x= -1; if($file = fopen("$path/$filename", "r")) { while(!feof($file)) { $therate = fgetss($file, 255); $x++; $count = $count + $therate; } fclose($file); } $average = ($count / $x); print("Surfer Average Rating for 12/24/99: "); printf("%.2f", $average); print("<br>Total Surfer Votes: $x"); ?>

  40. 9. Generating a random number from 0 to 9 <? srand(time()); $random = (rand()%9); print("Random number between 0 and 9 is: $random"); ?>

  41. 10. php simple slot machine - multiple random number generation <? function slotnumber() { srand(time()); for ($i=0; $i < 3; $i++) { $random = (rand()%3); $slot[] = $random; } print("<td width=\"33%\"><center>$slot[0]</td>"); print("<td width=\"33%\"><center>$slot[1]</td>"); print("<td width=\"33%\"><center>$slot[2]</td>"); </tr>

  42. 11. php simple slot machine - multiple random number generation <tr> <td width="100%" colspan="3" bgcolor="#008080"><form method="POST" action="example13.php3"><div align="center"><center><p><input type="submit" value="Spin!"></p> </center></div> </form> </td> </tr> </table> </center></div>

  43. 12. random text link advertising using predefined arraysmail, regular expressions, password protection <? $random_url = array("http://www.tdscripts.com/linkorg.html", "http://www.tdscripts.com/keno.html", "http://www.tdscripts.com/ezibill.shtml", "http://www.tdscripts.com/tdforum.shtml", "http://www.tdscripts.com/picofday.html", "http://www.tdscripts.com/gutsorglory.html");

  44. $url_title = array("Link Organizer", "TD Keno", "eziBill *Free Promotion!", "TD Forum", "TD Pic of Day PHP", "Guts or Glory Poker PHP"); $url_desc = array("- A comprehensive link list organizer", "- Offer your site visitors an engaging Keno game without the monetary risk", "- Sell access to and protect your membership area using iBill and our eziBill script", "- An unthreaded messageboard script to exchange ideas with your site visitors", "- Run your own picture of the day script from any site anywhere with this handy script", "- A casino-style card game written entirely in PHP");

  45. srand(time()); $sizeof = count($random_url); $random = (rand()%$sizeof); print("<center><a href=\"$random_url[$random]\">$url_title[$random]</a> $url_desc[$random]</center>"); ?>

  46. 13. forcing the text in a string to be all upper or lowercase <? // force all uppercase print(strtoupper("i bet this will show up as all letters capitalized<br>")); // force all lowercase print(strtolower("I BET THIS WILL SHOW UP AS ALL LETTERS IN LOWERCASE<br>")); // force the first letter of a string to be capitalized print(ucfirst("i bet this will show the first letter of the string capitalized<br>")); // force the first letter of each WORD in a string to be capitalized print(ucwords("i bet this will show the first letter of every word capitalized<br>")); ?>

  47. 14. searching through meta tags for a search engine <HTML> <BODY> <? $all_meta = get_meta_tags("010600.php3"); print($all_meta["description"]); print("<br>"); print($all_meta["keywords"]); ?> </BODY> </HTML>

  48. 15. searching through a directory and picking out files using a regular expression <? $diary_directory = opendir("."); while($filename = readdir($diary_directory)) { $filesplit = explode(".", $filename); $check_filename = $filesplit[0]; if(ereg("[0-9]{6}", $check_filename)) { $check_filename .= ".$filesplit[1]"; $valid_filename[] = $check_filename; } } closedir($diary_directory); for($index = 0; $index < count($valid_filename); $index++) { print("$valid_filename[$index]<br>"); } ?>

More Related