Slide 01-3 - Introduction To PHP
Slide 01-3 - Introduction To PHP
Slide 01-3 - Introduction To PHP
Objectives
To understand what PHP is and how a PHP sc ipt works script o ks with ith a Web Browser B o se and a Web Server To learn what software and components you need to get started with PHP
Content
1. What is PHP? 2. Develop and publish PHP scripts 3. PHP proper syntax 4. PHP comments
Content
1. What is PHP? 2. Develop and publish PHP scripts 3. PHP proper syntax 4. PHP comments
1. What is PHP?
Advantages
WebServer
(Internet connected)
2. Se n
d Req uest
for PH P
file
7. Web Browser Web Browser Phone Query Results: That is John Doe's Phone Number
nR etur 6. R
lts esu
Content
1. What is PHP? 2. Develop and publish PHP scripts 3. PHP proper syntax 4. PHP comments
10
You can alternatively start your PHP scripts with ith th the < <script> i t> t tag as f follows: ll
<script language="PHP"> print ("A simple initial script"); </script>
If have short_open_tag enabled in its configuration fi ti fil file, you can use <? ? and d ?>. ? If asp_tags is enabled in the PHP configuration file, you can use <% and %> as delimiters.
11
12
Content
1. What is PHP? 2. Develop and publish PHP scripts 3. PHP proper syntax 4. PHP comments
13
14
3. Proper Syntax
If you have a syntax error then you have written one or more PHP statements that are grammatically incorrect in the PHP language. The print statement syntax:
Enclose message in quotation marks print ( "Your message to print" ); Message to Output Parenthesis are optional End in a semi-colon
15
16
Be careful to use quotation marks, parentheses, and brackets in pairs. Most PHP commands end with a semicolon (;). Be careful of case. PHP ignores blank spaces.
way to use PHP is to embed PHP scripts within HTML tags in an HTML document.
17
1. <html> 2. <head> 3. <title>HTML With PHP Embedded</title> </head> 4. <body> y 5. <font size=5 color=blue>Welcome To My Page</font> 6. <?php 7. print ("<br> Using PHP is not hard<br>"); 8. ?> 9. and you can learn to use it quickly! 10. </body></html>
18
Sometimes you want to output an HTML tag th t also that l requires i double d bl quotation t ti marks. k
Use the backslash ( (\ \) character to signal that the double quotation marks themselves should be output: output:
print ("<font color=\ color=\"blue "blue\ \">"); The Th above b statement t t t would ld output: t t <font color="blue">
19
20
Content
1. What is PHP? 2. Develop and publish PHP scripts 3. PHP proper syntax 4. PHP comments
4. PHP Comments
Comments
enable you to include descriptive text along with the PHP script
Comment lines are ignored when the script runs; they do not slow down the runrun-time. Comments have two common uses.
Describe Describe
21
Syntax - Use //
Question?