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

PHP Lecture 3

PHP is a server-side scripting language used for web development. PHP files contain text, HTML tags, and scripts. PHP files are executed on the server and return HTML to browsers. MySQL is a database server that works with PHP to store and retrieve data from databases. PHP is free, runs on many platforms, and is easy to learn, making it a popular choice for web development.

Uploaded by

Razi Ejaz
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

PHP Lecture 3

PHP is a server-side scripting language used for web development. PHP files contain text, HTML tags, and scripts. PHP files are executed on the server and return HTML to browsers. MySQL is a database server that works with PHP to store and retrieve data from databases. PHP is free, runs on many platforms, and is easy to learn, making it a popular choice for web development.

Uploaded by

Razi Ejaz
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 22

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.)

What is a PHP File?


PHP files can contain text, HTML tags and scripts
PHP files are returned to the browser as plain HTML

PHP files have a file extension of ".php",

What is MySQL?
MySQL is a database server

MySQL is ideal for both small and large applications


MySQL supports standard SQL

MySQL compiles on a number of platforms


MySQL is free to download and use

Why PHP?
PHP runs on different platforms (Windows, Linux, Unix, etc.)
PHP is compatible with almost all servers used today (Apache, IIS, etc.) PHP is FREE to download from the official PHP resource: www.php.net PHP is easy to learn and runs efficiently on the server side

Where to Start?
To get access to a web server with PHP support, you can:
Install Apache (or IIS) on your own server, install PHP, and MySQL Or find a web hosting plan with PHP and MySQL support

<?php $myString = "Hello!"; echo $myString; echo "<h5>I love using PHP!</h5>"; ?>

<?php $my_string = "Hello Bob. My name is: "; $my_number = 4; $my_letter = a; echo $my_string; echo $my_number; echo $my_letter; ?>

<?php $my_string = "Hello Bob. My name is: "; echo "$my_string Bobettta <br />"; echo "Hi, I'm Bob. Who are you? $my_string <br />"; echo "Hi, I'm Bob. Who are you? $my_string Bobetta"; ?>

<?php $my_string = "Hello Bob. My name is: "; echo "$my_string Bobettta <br />"; echo "Hi, I'm Bob. Who are you? $my_string <br />"; echo "Hi, I'm Bob. Who are you? $my_string Bobetta"; ?>

$addition = 2 + 4; $subtraction = 6 - 2; $multiplication = 5 * 3; $division = 15 / 3; $modulus = 5 % 2; echo "Perform addition: 2 + 4 = ".$addition."<br />";

echo "Perform subtraction: 6 - 2 = ".$subtraction."<br />"; echo


"Perform multiplication: 5 * 3 = ".$multiplication."<br />"; echo "Perform division: 15 / 3 = ".$division."<br />"; echo "Perform modulus: 5 % 2 = " . $modulus . ". Modulus is the remainder after the division operation has been performed. In this case it was 5 / 2, which has a remainder of 1.";

$a_string = "Hello"; $another_string = " Billy"; $new_string = $a_string . $another_string; echo $new_string . "!";

$my_name = "someguy"; if ( $my_name == "someguy" ) { echo "Your name is someguy!<br />"; } echo "Welcome to my homepage!";

$my_name = anotherguy"; if ( $my_name == "someguy" ) { echo "Your name is someguy!<br />"; } echo "Welcome to my homepage!";

$number_three = 3;
if ( $number_three == 3 ) { echo "The if statement evaluated to true"; } else { echo "The if statement evaluated to false"; }

$employee = "Bob";
if($employee == "Ms. Tanner"){ echo "Hello Ma'am"; } elseif($employee == "Bob"){ echo "Good Morning Sir!"; } else { echo "Morning"; }

$destination = "Tokyo"; echo "Traveling to $destination<br />"; switch ($destination){ case "Las Vegas": echo "Bring an extra $500"; break; case "Amsterdam": echo "Bring an open mind"; break; case "Egypt": echo "Bring 15 bottles of PEPSI"; break; case "Tokyo": echo "Bring lots of money"; break; case "Caribbean Islands": echo "Bring a swimsuit"; break; }

$destination = "Tokyo"; echo "Traveling to $destination<br />"; switch ($destination){ case "Las Vegas": echo "Bring an extra $500"; break; case "Amsterdam": echo "Bring an open mind"; break; case "Egypt": echo "Bring 15 bottles of PEPSI"; break; case "Tokyo": echo "Bring lots of money"; break; case "Caribbean Islands": echo "Bring a swimsuit"; break; default: echo LEAVE IT!"; break; }

<html><body> <h4>Art Supply Order Form</h4> <form action="process.php" method="post"> <select name="item"> <option>Paint</option> <option>Brushes</option> <option>Erasers</option> </select> Quantity: <input name="quantity" type="text" /> <input type="submit" /> </form> </body></html>

<html> <body> <?php $quantity = $_POST['quantity']; $item = $_POST['item']; echo "You ordered ". $quantity . " " . $item . ".<br />"; echo "Thank you for ordering from Tizag Art Supplies!"; ?> </body> </html>

<?php function myGreeting($firstName){ echo "Hello there ". $firstName . "!<br />"; } myGreeting("Jack"); myGreeting("Ahmed"); myGreeting("Julie"); myGreeting("Charles");

?>

<?php function myGreeting($firstName, $lastName){ echo "Hello there ". $firstName . "!<br />"; } myGreeting("Jack", "Black"); myGreeting("Ahmed", "Zewail"); myGreeting("Julie", "Roberts"); myGreeting("Charles", "Schwab"); ?>

<?php function mySum($numX, $numY){ $total = $numX + $numY; return $total; } $myNumber = 0; echo "Before the function, myNumber = ". $myNumber ."<br />"; $myNumber = mySum(3, 4); echo "After the function, myNumber = " . $myNumber ."<br />";

?>

You might also like