1 / 5

PHP - Variables

PHP - Variables. Variable name: starts with a letter or _, followed by letters, _s, or digits PHP is a loosely typed language  no declaration of variables (like Perl) Variable names are case sensitive. PHP - Variables. $a = 3; $b = 1.43; $c = 1.3 e4; $d = 7E-10; $first1 = “Mike”; // ok

callum-levy
Download Presentation

PHP - Variables

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PHP - Variables • Variable name: starts with a letter or _, followed by letters, _s, or digits • PHP is a loosely typed language •  no declaration of variables (like Perl) • Variable names are case sensitive

  2. PHP - Variables • $a = 3; • $b = 1.43; • $c = 1.3 e4; • $d = 7E-10; • $first1 = “Mike”; // ok • $first2 = ‘Sarah’; // ok • $first3 = Jane; // ok

  3. PHP – Printing variables • $a = “Mike”; • Using double quotes; variables expand • echo “hello $a”; //  hello Mike • Using single quotes, variables do not expand • echo ‘hello $a’; //  hello $a

  4. PHP – Printing variables • We can also use the print function • print “Using print: Hello $a”; • print( “Using print( ): Hello $a” ); • print( “Printing using several<br> Lines” );

  5. PHP – Variable scope • A variable is in scope until the end of the PHP script

More Related