Introduction: ========= PHP is a powerful server-side scripting language for creating dynamic and intera ctive websites.
PHP is the widely-used, free, and efficient alternative to compe titors such as Microsoft's ASP. PHP is perfectly suited for Web development and can be embedded directly into the HTML code. The PHP syntax is very similar to P erl and C. PHP is often used together with Apache (web server) on various operat ing systems. It also supports ISAPI and can be used with Microsoft's IIS on Wind ows. Rasmus Lerdorf unleashed the first version of PHP way back in 1994. => => => => => => => PHP PHP PHP PHP PHP PHP PHP stands for PHP: Hypertext Preprocessor is a server-side scripting language, like ASP scripts are executed on the server files can contain text, HTML tags and scripts files are returned to the browser as plain HTML files have a file extension of ".php", ".php3", or ".phtml" is case sensitive
Advantages: ======== => PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreS QL, Generic ODBC, etc.) => PHP is an open source software => PHP is free to download and use => PHP runs on different platforms (Windows, Linux, Unix, etc.) => PHP is compatible with almost all servers used today (Apache, IIS, etc.) => PHP is easy to learn and runs efficiently on the server side => PHP combined with MySQL are cross-platform (you can develop in Windows and se rve on a Unix platform) => PHP supports a large number of major protocols such as POP3, IMAP, and LDAP. PHP4 added support for Java and distributed object architectures (COM and CORBA), making n-tier development a possibility for the first time.
Basic PHP Syntax: ============= A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document. On servers with shorthand support enabled you can start a scripting block with < ? and end with ?>. Alternate way to write PHP Scripting block is <script language="php">PHP codings</script> There are two basic statements to output text with PHP: --------------------------------------------------------------------echo print Comments in PHP: ============= In PHP, we use // to make a single-line comment or /* and */ to make a large com ment block. Variables in PHP: ============
and _ ) =>A variable name should not contain spaces. Variable Naming Rules: ----------------------------=>A variable name must start with a letter or an underscore "_" =>A variable name can only contain alpha-numeric characters and underscores (a-z . All variables in PHP start with a $ sign symbol. numbers or arrays. Syntax: ---------$var_name = value.Variables are used for storing a values. If a variable name is more than one word. PHP automatical ly converts the variable to the correct data type. PHP is a Loosely Typed Language: ======================== In PHP a variable does not need to be declared before being set. 0-9. like text strings. or with capitali zation ($myString)
. A-Z. In a strongly typed programming language. you have to declare (define) t he type and name of the variable before using it. depending on how they are set . it should be separated with underscore ($my_string).