Your SlideShare is downloading. ×
0
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Intro to PHP
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Intro to PHP

329

Published on

Published in: Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
329
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Note how the php is embedded directly in the HTML All php code is enclosed within the tag <?php ?> Echo function prints out a string to the output stream In this case the output stream is the actual HTML document
  • * Note that all variables begin with a $ sign, even arrays and objects
  • Now that we know the basics, lets see what we can do
  • Facebook uses mysql Being open source has many advantages - continually improving, highly available, free (mostly)
  • Transcript

    • 1. Intro to PHP Carl-Erik Svensson
    • 2. What is PHP? <ul><li>PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML* </li></ul>*Source: http://www.php.net
    • 3. Why Use PHP? <ul><li>Simple, yet powerful scripting tool </li></ul><ul><li>Easily format and display database information </li></ul><ul><li>It is popular </li></ul>Image Source: http://www.securityspace.com/s_survey/data/man.200709/apachemods.html
    • 4. The Basics
    • 5. The Results <ul><li>Output from a script goes directly into the HTML that is parsed </li></ul><ul><li>This is what is meant by a ‘dynamic’ webpage </li></ul>
    • 6. Some Syntax <ul><li>Generally C-like </li></ul><ul><li>Variables are not strongly typed </li></ul>
    • 7. Web Applications <ul><li>Form processing </li></ul><ul><li>Database manipulation </li></ul><ul><ul><li>Blogs </li></ul></ul><ul><ul><li>Forums </li></ul></ul><ul><ul><li>Facebook </li></ul></ul>
    • 8. PHP + MySQL = Sweet <ul><li>MySQL is an open source database software solution </li></ul><ul><li>Enables rich web applications when combined with PHP </li></ul>Image Source: http://www.mysql.com/
    • 9. Rainfall Application <ul><li>Read the contents of a database </li></ul><ul><li>Get the rainfall data </li></ul><ul><li>Parse the results </li></ul><ul><li>Display it </li></ul>
    • 10. Connecting to a Database <ul><li>PHP Has a set of functions that can be used with MySQL </li></ul><ul><li>First step is to setup a link to the desired database </li></ul>
    • 11. Making a Query <ul><li>Once a link is established, querying is easy </li></ul><ul><li>Errors for any given function are returned by mysql_error() </li></ul>
    • 12. MySQL Result Set <ul><li>The value returned by mysql_query() is a reference to an internal data structure </li></ul><ul><li>It can be parsed by various functions </li></ul>
    • 13. Associative Arrays <ul><li>An array that can be indexed by a string </li></ul><ul><li>A set of key-&gt;value pairs </li></ul><ul><li>Very similar to a hash in Perl </li></ul>
    • 14. PHP foreach <ul><li>Similar to the Perl equivalent </li></ul><ul><li>Allows iterating through each element of an array </li></ul>
    • 15. Put it All Together
    • 16. &nbsp;
    • 17. The Results http://128.174.242.224/PHPExamples/rainfall.php
    • 18. A Slight Improvement <ul><li>This was not the exact code we came up with </li></ul><ul><li>I added some titles and a neat trick </li></ul><ul><ul><li>Highlight every other row in the table </li></ul></ul><ul><ul><li>This makes information more readable </li></ul></ul>
    • 19. &nbsp;
    • 20. Samples <ul><li>USGS Example Rainfall </li></ul><ul><li>EC Awards Committee Scholarship Database </li></ul>
    • 21. What Else Can PHP Do? <ul><li>Command line scripting </li></ul><ul><li>Desktop applications </li></ul><ul><li>Anything </li></ul>
    • 22. Links <ul><li>PHP.net </li></ul><ul><li>PHP Manual </li></ul><ul><li>MySQL </li></ul>

    ×