Jump to content

PHP: Difference between revisions

236 bytes removed ,  28 September 2010
Remove legacy information.
(Remove legacy information.)
 
(2 intermediate revisions by one other user not shown)
Line 14: Line 14:
  cd ~/public_html
  cd ~/public_html


* Create a file called “hello.php” using a text editor.
* Create a file called ''hello.php'' using a text editor.


  nano hello.php
  nano hello.php
Line 20: Line 20:
* Type this PHP code into the file
* Type this PHP code into the file


#!/usr/local/bin/php
  <?php
  <?php
     echo "Hello World!";
     echo "Hello World!";
  ?>
  ?>
Notice the use of the hashbang (or shebang - yes, make all the jokes you want), which must be present at the top of every PHP file.
#!/usr/local/bin/php


* Save and exit (CTRL + O, CTRL + X)
* Save and exit (CTRL + O, CTRL + X)
Line 63: Line 57:
PHP variables can store any data you wish. They start with a $ sign and contain alphanumerical characters, but must always start with a letter.
PHP variables can store any data you wish. They start with a $ sign and contain alphanumerical characters, but must always start with a letter.
   
   
  $example1 = “example”;
  $example1 = "example";
  echo $example1;
  echo $example1;


This will output the text “example”.
This will output the text "example".


Variables as the name suggest can be altered after they're declared.
Variables as the name suggest can be altered after they're declared.


  $example1 = “altered example”;
  $example1 = "altered example";


$example1 now contains “altered example” and the previous contents are gone.
$example1 now contains "altered example" and the previous contents are gone.


[[Category:Helpdesk]]
[[Category:Helpdesk]]