php overview. c ontent introduction of php history and development basics of php programming
TRANSCRIPT
![Page 1: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/1.jpg)
PHP OVERVIEW
![Page 2: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/2.jpg)
CONTENT
Introduction of PHP
History and development
Basics of PHP programming
![Page 3: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/3.jpg)
WHAT IS PHP ?
PHP = Hypertext preprocessor
Server side scripting language
Used for development of dynamical webpages Part of typical LAMP combination Linux, Apache, MySQL and PHP
Includes a command line scripting possibility Can be used in graphical applications
![Page 4: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/4.jpg)
HOW IT WORKS
PHP code is usually embedded into HTML
Processing the code :1) The HTML code stands as it is
2) The PHP scripts are executed to create final HTML code
3) Both parts are combined and back
4) Resulting HTML is interpreted by a browser
![Page 5: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/5.jpg)
ADVANTAGES OF PHP
Freely available The PHP group provides complete source
code free of charge Similar syntax to C, Pearl Works with many operating systems Can be deployed on many web servers Interacts with lots of databases It is supported by many providers of
webhosting
![Page 6: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/6.jpg)
HISTORY – INITIAL DEVELOPMENT Originally created by Rasmus Lerdorf
PHP originally stood for Personal Home Page Replaces small set of Pearl scripts Used as a tool for observing traffic on webpage
PHP 2 (PHP/FI) First publicly released version (on June 8, 1995) Combination of Lerdorf’s Form Interpreter and
original binary from PHP Was able to communicate with databases Enabled the building of dynamical web
application included Perl-like variables, form handling, and
the ability to be embedded HTML
![Page 7: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/7.jpg)
HISTORY – RELEASED VERSIONSPHP (PHP: Hypertext Preprocessor) was created by Rasmus Lerdorf in
1994. It was initially developed for HTTP usage logging and server-side form generation in Unix.
PHP 2 (1995) transformed the language into a Server-side embedded scripting language. Added database support, file uploads, variables, arrays, recursive functions, conditionals, iteration, regular expressions, etc.
PHP 3 (1998) added support for ODBC data sources, multiple platform support, email protocols (SNMP,IMAP), and new parser written by Zeev Suraski and Andi Gutmans .
PHP 4 (2000) became an independent component of the web server for added efficiency. The parser was renamed the Zend Engine. Many security features were added.
PHP 5 (2004) adds Zend Engine II with object oriented programming, robust XML support using the libxml2 library, SOAP extension for interoperability with Web Services, SQLite has been bundled with PHP
![Page 8: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/8.jpg)
CURRENT VERSION - PHP 5
The most recent extension (the 5.2.6) was published on May 1, 2008
Uses enhanced Zend II engine
It includes : support for object-oriented programming, the PHP Data Objects extension (simplifies
accessing databases) numerous performance enhancements
![Page 9: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/9.jpg)
WEBSITES USING PHP
More than 20 million Internet domains are hosted on servers with PHP installed
Significant examles User-facing portion of Facebook Wikipedia (MediaWiki) Yahoo! MyYearbook
![Page 10: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/10.jpg)
WHAT DO YOU NEED TO WORK WITH PHP?
If your server supports PHP You don’t need anything Just create some .php files in your web directory
If your server does not support PHP, you must install PHP. Download PHP Download database (MySQL) Download server (Apache)
![Page 11: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/11.jpg)
BASICS OF SYNTAX
Scripting block starts with <?php and ends with ?>
Each code line in PHP must end with a (;)
Comments // ,# comment /* comment */ Writing of the plain textEcho “text”print “text”
![Page 12: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/12.jpg)
VARIABLES IN PHP
Each variable starts with $ symbol
Variable name can contain only a-Z,0-9,_
It does not need to be declared before its setting.
<?php $txt = "Hello World!"; $number = 16;
?>
![Page 13: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/13.jpg)
VARIABLE TYPES
Numerical Integer – positive as well as negative, including 0 Float – real numbers, 14 digits accuracy
Logical Boolean - True x False, not case sensitive
Alphabetical String – set of characters
![Page 14: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/14.jpg)
WORKING WITH VARIABLES
Settype($var, “integer”) allows you to set variable according to your wish
Gettype() write the type of variable
(.) Connects 2 variables of string type
strlen() finds the length of a string
![Page 15: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/15.jpg)
PHP OPERATORS
![Page 16: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/16.jpg)
LOGICAL OPERATORS
&& = and || = or
At least one of condition is fulfilled ! = not xor
Exactly one statement is evaluated as true
![Page 17: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/17.jpg)
CONDITIONAL STATEMENTS
If/ else After each statement stands (;) If more than one command should be executed,
use curly braces { }
Switch / break Used for choosing one possibility from multiple
casesSwitch ($var )
{ case : “x” : echo “good”; break;default : echo “wrong input” ;}
![Page 18: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/18.jpg)
ARRAYS IN PHP
Numeric array Each element of array has its ID number (first
0!!) $names = array("Petr“,"Joe"); $names[0] = "Petr";
Associative Arrays Each element is assigned its value $ages = array("Peter"=>32, "Joe"=>34); $ages['Peter'] = "32";
![Page 19: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/19.jpg)
MULTIDIMENSIONAL ARRAYS
element of array is also an array
$families = array ("Griffin"=>array
( "Peter", "Lois", "Megan" ), "Soltis" =>array
(“Johny", "Morgan" ))
![Page 20: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/20.jpg)
PHP LOOPING
while loops repeat until final condition is reached$i =1;while ($i<=10)
{ echo $i; $i++; }
do...while kind of reversed while function Do { code to be executed;} While(final condition);
![Page 21: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/21.jpg)
PHP LOOPING
for Repeats the specific part of code so many times
we choose
for ($i=1; $i<=10; $i++)
Initial condition final condition running decsription
![Page 22: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/22.jpg)
HTML INSIDE PHP
If inside quotes, the Html tags are returned as a text by PHP module
Treated as a HTML tag by
<?phpecho "<TR>
<TD>".$i."</TD><TD>".$i*$i."</TD></TR>\n";
?>
![Page 23: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/23.jpg)
PHP FUNCTIONS
All function starts with function($parameter)
Requirements for naming functions are same as these for variables
The { mark opens the function code, while } mark closes it
It can have either defined or no parameter
More than 700 built-in functions available
![Page 24: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/24.jpg)
PHP FORMS AND USER INPUT
Used to gain information from users by means of HTML
Information is worked up by PHP<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
![Page 25: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/25.jpg)
THE $_GET VARIABLE
Used to collect values from a form Displays variable names and values are in the
URL http://www.w3schools.com/welcome.php?
name=jo&age=39 Can send limited amount of information (max.
100 characters)<html>
<body>
Welcome <?php echo $_GET["name"]; ?> <br />
You are <?php echo $_GET["age"]; ?> years old
</body>
</html>
![Page 26: PHP OVERVIEW. C ONTENT Introduction of PHP History and development Basics of PHP programming](https://reader034.vdocument.in/reader034/viewer/2022052414/56649ee55503460f94bf5770/html5/thumbnails/26.jpg)
THE $_POST VARIABLE
Used to collect values from a form Information from a form is invisible No limits on the amount of information to be
send
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br />
You are <?php echo $_POST["age"]; ?> years old.
</body>
</html>