Tag Archives: variables

Learning PHP The Right Way vol 1

Notes for myself from youtube tutorial Full PHP 8 Tutorial - Learn PHP The Right Way by Program With Gio. Video nr 3: Basic PHP Syntax - PHP 8 Tutorial
  1. If the file contains only php code, there is no need to add the final
    ?>
    ending.
  2. There is no need for ending semicolon if:
    • it is the only line between php-tags
      <?php echo "Hello" ?>
    • it is the last line of the file before ending
      ?>
      tag.
  3. echo is faster than print and latter returns value 1
    <?php echo print "Hello"?>
    returns
    Hello1
  4. $this refers to object, so you can't get it as a variable's name.
  5. Variables can be sign as reference—if value changes, you change too!
    <?php 
    $x = 3;
    $z=&$x; 
    $x=1;
    echo $z
    ?>
    returns
    1