0% found this document useful (0 votes)
13 views19 pages

Chapter 2

Uploaded by

Nge Sue
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views19 pages

Chapter 2

Uploaded by

Nge Sue
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

University of Computer Studies, Pyay

Daw Aye Aye Theint


Lecturer
ITSM

1
Outlines
Installing PHP

Writing PHP Statements

Running Your First PHP Script(Testing)

Documenting the Script

2
Installing PHP
To create and run PHP scripts, you need to have a few things in place:
A computer running Web server software, such as Apache or Internet Information Server
(IIS).
The PHP server module installed on the same computer. This module talks to the Web
server software; this is the PHP engine that actually does the work of running your PHP
scripts.
If you want to build database - driven Web applications — you also need a database
server installed. Options include MySQL, PostgreSQL, and SQL Server.

3
Help with PHP
Install the Web server.
 web server and database at the local host

Ø popular software package for windows is XAMPP: includes apache, mysql, php.
Ø Download for free here: https://www.apachefriends.org/
Ø How to install XAMPP for Windows : https://www.wikihow.com/Install-XAMPP-for-Windows

 Install NuSphere PhpED


 http://www.nusphere.com/

4
Help with PHP
Step 1: Step 2:

5
Help with PHP
Step 3: Step 4:

6
Help with PHP
Step 5: Step 6:

7
Help with PHP
Step 7: Step 8:

8
Help with PHP
Step 9: Step 10:

9
Help with PHP
Step 11:

 Enter the serial number.

10
Help with PHP
Step 12:

 File → New

11
Writing PHP Statements
The echo statement: to display output.
Syntax:

echo “Hi”;
An echo statement says to output everything that is between the double quotes (" ").
PHP simple statements end with a semicolon (;).
Warning! - Leaving out the semicolon is a common error.

Parse error: expecting `’,’’ or `’;’’ in file.php on line 6

12
Writing PHP Statements
Add the PHP code to the HTML file name with .php or .phtml extension.
Add PHP code to your Web page by using tags to other tags in the HTML file.

<?php
...
PHP statements
...
?>

13
Writing Your HTML Script
You may have written a Hello World program in HTML. (save as: hello.html)

<html>
<head>
<title>Hello World HTML Program</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>

14
Writing Your First PHP Script
 An example of a simple PHP file, with a PHP script that sends the text “Hello World!”. (save
as: hello.php.
<html>
<head><title>Hello World Script</title>
</head>
<body>
<h1>My first PHP page</h1>
<?php
echo "<p>Hello World!</p>";
?>
</body>
</html>

15
Running Your First PHP Script(Testing)
An example of a simple PHP file save as hello.php at:

c:/xampp/htdocs/ucsyPHP/
Run the hello.php at browser :

http://localhost/ucsyPHP/hello.php

In the browser :
My first PHP page
Hello World!

16
Documenting the Script
Comments are note that are embedded in the script itself.
PHP ignores comments.
Can embed comments in the script of anywhere.
The format for comments is as follows:

Ø One line comment with //


Ø Multiline comment with /* */

17
Example using Comments
Save as: comment.php

<html> Output:
<body> Hello World!
<?php
// This is a PHP comment line
/* This is a PHP
comment block
*/
echo "Hello World!";
?>
</body>
</html>

18
Thank You

19

You might also like