Presentation is loading. Please wait.

Presentation is loading. Please wait.

Simple PHP An Introduction.

Similar presentations


Presentation on theme: "Simple PHP An Introduction."— Presentation transcript:

1 Simple PHP An Introduction

2 Interpreting PHP Local Machine: Live Server Interpreter compiles code
Run WAMP, LAMP, or MAMP in background & Access pages through it Live Server Most hosts provide PHP interpreter Interpreter compiles code Translates to displayable HTML Performs other operations

3 File Extension – Web Page
.php Lets server know it needs to pass that code to interpreter If page would have been HTML, still have regular doctype definition and other HTML <!doctype html>

4 File Extension – Style SHeet
.php 1st line in file must be: <?php header(“content-type: text/css”); ?> When link stylesheet to html, code is the same except for altered file extension Ex: <link href="stylephp.php" rel="stylesheet" type="text/css" />

5 Embedding PHP <?php ?> PHP can be Only code in file
Embedded in portions along with other HTML Embedded in portions along with CSS <?php ?> Your Code Goes Here!

6 <body> <h2>This is the first PHP coding section</h2> <?php echo "This is <i>PHP code</i>\n"; ?> <h2>This is the second PHP coding section</h2> <?php echo "This is <b>more</b> PHP code\n"; ?> </body>

7 //nothing on this line will run or display ?>
Comments <?php //nothing on this line will run or display ?> <?php /* This is a multiline comment. I can keep typing until I close the comment off */ ?>

8 Outputting Display Text & HTML
Command: echo To have output display on page, php between body tags Can output numbers without surrounding characters Text must be surrounded with double or single quotes

9 <?php echo 15; //outputs the number 15 onto the web page echo "<br />"; //outputs a break onto the web page echo "this is a sentence"; //outputs text onto web page echo 'this is also a sentence'; //outputs text ?>

10 <head> </head> <?php echo “<title> My Webpage
?> </head>

11 Simple Math Operator Symbol Operation Performed + Addition -
Subtraction * Multiplication / Division % Modulus (finds remainder of division problem)

12 <body> <?php echo "5+5="; //with quotes, displays literal text echo 5+5; //without quotes, performs calculation echo "<br />"; echo "10-5="; echo 10-5; ?> </body>

13 Example Full Page + PHP

14 Example Stylesheet + PHP


Download ppt "Simple PHP An Introduction."

Similar presentations


Ads by Google