Documents

PHP doc.pdf

Categories
Published
of 19
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Description
P H P 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 .p
Transcript
    What is PHP?  PHP stands for P HP: H ypertext P reprocessor  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 What is MySQL?  MySQL is a small database server  MySQL is ideal for small and medium applications  MySQL supports standard SQL  MySQL compiles on a number of platforms  MySQL is free to download and use PHP + MySQL  PHP combined with MySQL are cross-platform (means that you can develop in Windows andserve on a Unix platform) 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 theofficial PHP resource: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 You cannot view the PHP source code by selecting View source in the browser-you willonly see the output from the PHP file, which is plain HTML. This is because the scripts areexecuted on the server before the result is sent back to the browser.  Basic PHP Syntax A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.Below, we have an example of a simple PHP script which sends the text Hello World to thebrowser: <html><body><?php echo Hello World ; ?></body></html> A PHP scripting block always starts with <?php and ends with ?> . A PHP scripting block can beplaced anywhere in the document.Each code line in PHP must end with a semicolon. The semicolon is aseparator and is used todistinguish one set of instructions from another.There are two basic statements to output text with PHP: echo and print . In the example above wehave used the echo statement to output the text Hello World . Variables in PHP All variables in PHP start with a $ sign symbol. Variables may contain strings, numbers, or arrays.Below, the PHP script assigns the string Hello World to a variable called $txt: <html><body><?php$txt= Hello World ;echo $txt;?></body></html> To concatenate two or more variables together, use the dot (.) operator: <html><body><?php$txt1= Hello World ;$txt2= 1234 ;echo $txt1 . . $txt2 ;?></body></html> The output of the script above will be: Hello World 1234 .  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 comment/*This isa commentblock*/?></body></html> Operators are used to operate on values. PHP Operators This section lists the different operators used in PHP. Arithmetic OperatorsOperatorDescriptionExampleResult +Additionx=2x+24-Subtractionx=25-x3*Multiplicationx=4x*520 /Division15/55/232.5%Modulus (division remainder)5%210%810%2120++Incrementx=5x++x=6--Decrementx=5x--x=4 Assignment OperatorsOperatorExampleIs The Same As =x=yx=y   +=x+=yx=x+y-=x-=yx=x-y*=x*=yx=x*y /=x/=yx=x/y%=x%=yx=x%y  Comparison OperatorsOperatorDescriptionExample ==is equal to5==8 returns false   !=is not equal5!=8 returns true>is greater than5>8 returns false<is less than5<8 returns true>=is greater than or equal to5>=8 returns false<=is less than or equal to5<=8 returns true Logical OperatorsOperatorDescriptionExample &&andx=6y=3(x < 10 && y > 1) returns true||orx=6y=3(x==5 || y==5) returns false!notx=6y=3!(x==y) returns true Conditional statements in PHP are used to perform different actions based on differentconditions. Conditional Statements Very often when you write code, you want to perform different actions for different decisions. Youcan use conditional statements in your code to do this.In PHP we have two conditional statements:  if (...else) statement -use this statement if you wantto execute a set of code when acondition is true (and another if the condition is not true)  switch statement -use this statement if you want to select one of many sets of lines toexecute
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks