Archy Will He
0
Q:

php tutorial

// Firstly you must have PHP installed & running a web server
// This could be Apache, Nginx, etc...
// Or for quick testing purposes and for the purpose
// of this example, you could run
// PHP's own dev server from a shell
php -S 127.0.0.1:8080 -t your-web-directory-location
// This will start a web server on localhost port 8080
// The -t switch sets the document root, this is where your
// home page, typically index.php will be situated

// very basic index.php example
<?php
	echo "Hello, world!";   
?>
  
// You can now go to a browser and enter 127.0.0.1:8080
// You will presented with your simple web page
// Hello, world!
3
<?php
class BaseClass {
   public function test() {
       echo "BaseClass::test() called\n";
   }
   
   final public function moreTesting() {
       echo "BaseClass::moreTesting() called\n";
   }
}

class ChildClass extends BaseClass {
   public function moreTesting() {
       echo "ChildClass::moreTesting() called\n";
   }
}
// Results in Fatal error: Cannot override final method BaseClass::moreTesting()
?>
1
<?php $a = “Hello Edureka!”; $b = ‘Hello Edureka!’; echo $a; echo “<br>”; echo $b; ?>
1

    <?php
class Fruit {
  // Properties
  public 
    $name;
  public $color;

  // Methods
  function 
    set_name($name) {
    
    $this->name = $name;
  }
  function get_name() {
    
    return $this->name;
  }
}

$apple = new Fruit();

    $banana = new Fruit();
$apple->set_name('Apple');
$banana->set_name('Banana');

    
echo $apple->get_name();
echo "<br>";

    echo $banana->get_name();
?>
 
0

<?php

$txt = "PHP";

echo "I love $txt!";

?>
-1
<?php
  
  // This is a comment
  
  echo 'Hello, World!';
  
  // And this outputs Hello, World!
  
?>
-2

New to Communities?

Join the community