Changes

Jump to navigation Jump to search
796 bytes added ,  16:54, July 11, 2007
all variables begin with a dollar sign - makes string embedding easy
Line 6: Line 6:     
PHP is an ''interpreted language'' (like Perl) and not a ''compiled'' one (like [[Java]] or [[C]]).  
 
PHP is an ''interpreted language'' (like Perl) and not a ''compiled'' one (like [[Java]] or [[C]]).  
 +
 +
==String handling==
 +
 +
The [[string concatenation]] operator is the period (or full stop). This is a big difference from most other languages, which use a plus sign or ampersand.
 +
 +
Example:
 +
 +
<code>
 +
  $first = "car";
 +
  $second = "nation";
 +
  $product= $first . $second;
 +
 +
  // Equivalent to:
 +
  $product= "carnation"
 +
 +
PHP recognizes variable names within strings which are enclosed in double quotes.
 +
Since all variables begin with a dollar sign, it is easy to embed one string inside another. This is the preferred way to create HTML output.
 +
 +
For example:
 +
 +
    $first = "John";
 +
    $middle = "Quincy"
 +
    $last = "Adams";
 +
   
 +
    // Show full name, in bold format
 +
    $echo <nowiki>"<B>$first $middle $last</B>";</nowiki>
 +
 +
 +
This outputs <nowiki>"<B>John Quincy Adems</B>"</nowiki> to the HTML page.
    
==Databases==
 
==Databases==
Siteadmin, Check users, nsTeam1RO, nsTeam1RW, nsTeam1_talkRO, nsTeam1_talkRW, oversight, Administrators
30,650

edits

Navigation menu