php_mysql - PHP/MySQL Tutorial PHP/MySQL Tutorial...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: PHP/MySQL Tutorial PHP/MySQL Tutorial Introduction to Database Goal of this tutorial Goal of this tutorial Not to teach everything about PHP, but provide the basic knowledge Explain code of examples Provide some useful references PHP == Hypertext Preprocessor Open-source, server-side scripting language Used to generate dynamic web-pages PHP scripts reside between reserved PHP tags This allows the programmer to embed PHP scripts within HTML pages What is PHP? What is PHP? What is PHP (contd) What is PHP (contd) Interpreted language, scripts are parsed at run- time rather than compiled beforehand Executed on the server-side Source-code not visible by client View Source in browsers does not display the PHP code Various built-in functions allow for fast development Compatible with many popular databases What does PHP code look like? What does PHP code look like? Structurally similar to C/C++ Supports procedural and object-oriented paradigm (to some degree) All PHP statements end with a semi-colon Each PHP script must be enclosed in the reserved PHP tag <?php ?> Comments in PHP Comments in PHP Standard C, C++, and shell comment symbols // C++ and Java-style comment # Shell-style comments /* C-style comments These can span multiple lines */ Variables in PHP Variables in PHP PHP variables must begin with a $ sign Case-sensitive ($Foo != $foo != $fOo) Global and locally-scoped variables Global variables can be used anywhere Local variables restricted to a function or class Certain variable names reserved by PHP Form variables ($_POST, $_GET) Server variables ($_SERVER) Etc. Variable usage Variable usage <?php $foo = 25; // Numerical variable $bar = Hello; // String variable $foo = ($foo * 7); // Multiplies foo by 7 $bar = ($bar * 7); // Invalid expression ?> Echo Echo The PHP command echo is used to output the parameters passed to it The typical usage for this is to send data to the clients web-browser Syntax void echo (string arg 1 [, string arg n ...]) In practice, arguments are not passed in parentheses since echo is a language construct rather than an actual function Echo example Echo example Notice how echo 5x5=$foo outputs $foo rather than replacing it with 25 Strings in single quotes ( ) are not interpreted or evaluated by PHP This is true for both variables and character escape-sequences (such as \n or \\) <?php $foo = 25; // Numerical variable $bar = Hello; // String variable echo $bar; // Outputs Hello echo $foo,$bar; // Outputs 25Hello echo 5x5=,$foo; // Outputs 5x5=25 echo 5x5=$foo; // Outputs 5x5=25 echo 5x5=$foo; // Outputs 5x5=$foo ?> Arithmetic Operations Arithmetic Operations $a - $b // subtraction $a * $b // multiplication $a / $b // division $a += 5 // $a = $a+5 Also works for *= and /= <?php $a=15; $b=30; $total=$a+$b; Print $total; Print <p><h1>$total</h1>; // total is 45 ?> Concatenation...
View Full Document

Page1 / 40

php_mysql - PHP/MySQL Tutorial PHP/MySQL Tutorial...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online