0% found this document useful (0 votes)
32 views

PHP Presentation 1 (Intro, Installation, Basics)

PHP Presentation

Uploaded by

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

PHP Presentation 1 (Intro, Installation, Basics)

PHP Presentation

Uploaded by

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

An Introduction to PHP with MySQL

Presented by
Archie G. Santiago
Arellano University
Professor – Computer Science D
INTRODUCTION TO PHP
WHAT IS PHP?

PHP stands for PHP: Hypertext Preprocessor


PHP is a server-side scripting language, like ASP
PHP scripts are executed on the server
PHP supports many databases (MySQL, Informix, Oracle,
Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
PHP is an open source software (OSS)
PHP is free to download and use
What is a PHP File?

•PHP files may contain text, HTML tags and scripts

•PHP files are returned to the browser as plain HTML

•PHP files have a file extension of ".php", ".php3", or ".phtml"


Why PHP?

➢PHP runs on different platforms (Windows, Linux, Unix,


etc.)

➢PHP is compatible with almost all servers used today


(Apache, IIS (Internet Information Services), etc.)

➢PHP is FREE to download from the official PHP


resource: http://www.php.net/
PHP is easy to learn and runs efficiently on the server side
Where to Start?

•Install an Apache server on a Windows or Linux


machine

•Install PHP on a Windows or Linux machine

•Install MySQL on a Windows or Linux machine


PHP INSTALLATION
Basic Requirements

If your server supports PHP - you don't need


to do anything! You do not need to compile
anything or install any extra tools - just
create some .php files in your web directory -
and the server will parse them for you. Most
web hosts offer PHP support.
Basic Requirements

✓Download XAMPP Server


Download for free here:
https://www.apachefriends.org/index.html

Or you can also use:


✓ WAMPServer
Download for free here:
https://www.wampserver.com/
INSTALLATION

✓ ApacheFriends XAMPP
✓ Apache
✓ MySQL
✓ PHP
✓ Perl
✓ SQLite
✓ PHPMyAdmin

✓ Wamp Server 5.0 (includes also Apache, MySQL, PHP


and PHPMyAdmin)
INSTALLATION

* System Requirements:

+ 2 GB RAM (recommended)
+ 850 MB free Fixed Disk
+ Supports: Windows 2008, 2012, Vista, 7, 8, 10
(Important: XP or 2003 not supported)
QUICK INSTALLATION

✓Step 1: Unpack the package into a directory of your


choice.

✓Step 2: Please start "setup_xampp.bat".

✓Step 3: If installation ends successfully, start the


Apache 2 with "apache_start".bat", MySQL
with"mysql_start".bat". Stop the MySQL Server with
"mysql_stop.bat". For shutdown the Apache HTTPD, only
close the Apache Command (CMD).
QUICK INSTALLATION

Step 4: Start your browser and type http://127.0.0.1 or


http://localhost in the location bar. You should see our pre-
made start page with certain examples and test screens.

NOTE:

To locate or open your PHP files:

1. In the web browser address bar type in:


localhost/foldername

example: localhost/mywebpage
REMINDERS:

Before you run PHP Scripts:

✓ Start WAMP Server (Run all services)

✓Run PHP scripts from the server (localhost or


http://127.0.0.1)

✓The PHP scripts or files should be save in:


C:\xampp\htdocs\<foldername>
The PHP Fundamentals
PHP SYNTAX

A PHP file normally contains HTML tags, just


like an HTML file, and some PHP scripting code.
Below, is an example of a simple PHP script
which sends the text “WELCOME TO PHP" to the
browser:
<html>
<body>
<?php
echo “WELCOME TO PHP";
?>
</body>
</html>
PHP SYNTAX

Declaring PHP:
•A PHP scripting block always starts with <?php
and ends with ?>. A PHP scripting block can be
placed anywhere in the document.

•Each code line in PHP must end with a semicolon.


The semicolon is a separator and is used to
distinguish one set of instructions from another.
<?
PHP Code In Here
You can also use the ?>
following format, it
will work the same <?php
way PHP Code In Here
php?>

<script language="php">
PHP Code In Here
</script>
PHP SYNTAX

There are two basic statements to output text


with PHP: echo and print.

Syntax:

a. echo b. print
echo “your text here” print(“Your text here”);
echo $variable print($variable);
In the given example we have used the echo
statement to output the text “WELCOME TO
PHP".
VARIABLES IN PHP

•All variables in PHP start with a $ sign symbol.

•Variables may contain strings, numbers, or arrays.


Example:

<html>
<body>
<?php
$txt=“COMPUTER SCIENCE";
echo $txt;
?>
</body>
</html>

In this example, the PHP script assigns the string


“COMPUTER SCIENCE" to a variable called $txt.
We can also concatenate two or more variables together, by
using the dot (.) operator:
Example:
<html>
<body>
<?php
$txt1="Hello World";
$txt2="1234";
echo $txt1 . " " . $txt2 ;
?></body>
</html>
The output of the script above will be: "Hello World 1234".
HOW TO PUT COMMENTS IN PHP?

In PHP, we use // to make a single-line comment or


/* and */ to make a large comment block.
<html>
<body>
<?php
//This is a single-line comment
/*This is a multi-line
or a comment
block*/
?>
</body></html>
REMINDERS:

You cannot view the PHP source code by


selecting "View source" in the browser - you will
only see the output from the PHP file, which is plain
HTML. This is because the scripts are executed on
the server before the result is sent back to the
browser.

You might also like