290 likes | 367 Views
I213-Dynamic Web Solutions. Introduction to PHP. Objectives. What is PHP? PHP history Versions PHP IDE’s Basic Syntax. What is PHP?.
E N D
I213-Dynamic Web Solutions Introduction to PHP
Objectives • What is PHP? • PHP history • Versions • PHP IDE’s • Basic Syntax
What is PHP? • PHP is a computer scripting language originally designed for producing dynamic web pages. It is primarily used for server-side scripting, but can be used from a command line interface or in standalone graphical applications. • http://www.php.net/manual/en/index.php
PHP History • PHP was originally created by RasmusLerdorf in 1995 and was written in the C programming language. • PHP originally stood for Personal Home Page. • It was used to perform tasks such as displaying his résumé and recording how much traffic his page was receiving and could connect to a database.
PHP History • He released PHP publicly in 1996 to speed up the finding of bugs and improving the code. • This release was named PHP version 2 and already had the basic functionality that PHP has today. • This included Perl-like variables, form handling, and the ability to embed HTML. The syntax was similar to Perl but was more limited, simpler.
PHP History • Zeev Suraski and Andi Gutmans, two Israeli’s rewrote the parser in 1997 and formed the base of PHP 3, changing the language's name to PHP: Hypertext Preprocessor. • The official launch came in June 1998. • They also founded Zend Technologies which manages the development of PHP.
Choosing a PHP IDE http://coding.smashingmagazine.com/2009/02/11/the-big-php-ides-test-why-use-oneand-which-to-choose/
Script Tags • <?php ?> • If short tags are enabled in PHP.ini:<? ?> • But short tags may not be enabled in all servers
Using PHP to output HTML <tags> PHP functions
echo vs. print • Print always returns a value • Echo performs slightly faster http://www.learnphponline.com/php-basics/php-echo-vs-print
End of statement • The semicolon(;) is compulsory • echo “Hello World”;
Comments // PHP comment /*This is a multi-line Comment */ # PHP comment
PHP Variables • PHP variables are prefixed by the “$”character. • $some_php_variable For a variable name to be valid, it must: • start with a letter or underscore • followed by any number of letters, numbers, or underscores
PHP Data Types • http://www.phpknowhow.com/basics/data-types/
Case-Sensitivity • Yes for variables, • No for function-names and reserved words
PHP Constants • Constants hold values that don’t get changed during the runtime of a script. • Same naming rules apply for constants except that $ sign is not used when defining constants. • To give an emphasis to constants, it’s a common practice to define constant names in UPPER-CASE
Constant Example Once defined, a new value cannot be assigned to a constant.
Case-Sensitivity • Yes for variables, • No for function-names and reserved words
Strings Delimited by single-quotes, double-quotes: