Mobirise Website Generator

INTRODUCTION TO PHP

Lesson 3.

• PHP is server side scripting system

    – PHP stands for "PHP: Hypertext Preprocessor"

    – Syntax based on Perl, Java, and C

    – Very good for creating dynamic content

    – Powerful, but somewhat risky!

    – If you want to focus on one system for dynamic content, this is a good one to choose


PHP Scripts

  • Typically file ends in .php - this is set by the web server configuration
  • Separated in files with the <?php ?> tag
  • php commands can make up an entire file, or can be contained in html - this is a choice….
  • Program lines end in ";" or you get an error
  • Server recognizes embedded script and executes
  • Result is passed to browser, source isn't visible


Parsing

  • We've talk about how the browser can read a text file and process it, that's a basic parsing method
  • Parsing involves acting on relevant portions of a file and ignoring others
  • Browsers parse web pages as they load
  • Web servers with server side technologies like php parse web pages as they are being passed out to the browser
  • Parsing does represent work, so there is a cost


Two Ways

  • You can embed sections of php inside html:

            <BODY>

            <P>

            <?php $myvar = "Hello World!";

            echo $myvar;

            </BODY>

  • Or you can call html from php:

            <?php

            echo "<html><head><title>Howdy</title>

            

            ?>


What do we know already?

  • Much of what we learned about javascript holds true in php (but not all!), and other languages as well

                $name = "bil";

                echo "Howdy, my name is $name";

                echo "What will $name be in this line?";

                echo 'What will $name be in this line?';

                echo 'What's wrong with this line?';

                if ($name == "bil")

                {

                // Hey, what's this?

                echo "got a match!";

                }

Advertise Your Products & Services Here

Mail: info@fast.org.ng

Call: +234 706 883 3966


We encourage you to visit the library and find some resource materials to facilitate your learning.


Ask your questions and comments below

Your questions and comments should be based on the lesson.