Changes

Jump to navigation Jump to search
178 bytes added ,  04:52, February 2, 2017
→‎Concatenation: style fix--the code is a wreck, but it looks nice when rendered.
Line 20: Line 20:  
Example:
 
Example:
   −
<code>
+
{{QuoteBox|<nowiki>$first = "car";</nowiki><br />
−
  $first = "car";
+
<nowiki>$second = "nation";</nowiki><br />
−
  $second = "nation";
+
<nowiki>$product= $first . $second;</nowiki><br />
−
  $product= $first . $second;
+
<br />
−
+
<nowiki>// Equivalent to:</nowiki><br />
−
  // Equivalent to:
+
<nowiki>$product= "carnation"</nowiki>}}
−
  $product= "carnation"
  −
</code>
      
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.
 
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.
Line 33: Line 31:  
For example:
 
For example:
   −
<code>
+
{{QuoteBox|<nowiki>$first = "John";</nowiki><br />
−
    $first = "John";
+
<nowiki>$middle = "Quincy"</nowiki><br />
−
    $middle = "Quincy"
+
<nowiki>$last = "Adams";</nowiki><br />
−
    $last = "Adams";
+
     <br />
−
      
+
<nowiki>// Show full name, in bold format</nowiki><br />
−
    // Show full name, in bold format
+
<nowiki>echo "<B>$first $middle $last</B>";</nowiki>}}
−
    echo <nowiki>"<B>$first $middle $last</B>";</nowiki>
  −
</code>
      
This outputs <nowiki>"<B>John Quincy Adams</B>"</nowiki> to the HTML page.
 
This outputs <nowiki>"<B>John Quincy Adams</B>"</nowiki> to the HTML page.
Block, SkipCaptcha, Upload, Automoderated users, Check users, delete, edit, Moderators, move, oversight, protect, ratelimit-exempt, rollback, Administrators
20,219

edits

Navigation menu