class Student {
public function \_\_construct($name) {
$this->name = $name;
}
}
$alex = new Student("Alex");
See: Classes
const MY\_CONST = "hello";
echo MY_CONST; # => hello
# => MY\_CONST is: hello
echo 'MY\_CONST is: ' . MY_CONST;
# This is a one line shell-style comment
// This is a one line c++ style comment
/\* This is a multi line comment
yet another line of comment \*/
<?php // begin with a PHP open tag.
$fruit = 'apple';
echo "I was imported";
return 'Anything you like.';
?>
<?php
include 'vars.php';
echo $fruit . "\n"; # => apple
/\* Same as include,
cause an error if cannot be included\*/
require 'vars.php';
// Also works
include('vars.php');
require('vars.php');
// Include through HTTP
include 'http://x.com/file.php';
// Include and the return statement
$result = include 'vars.php';
echo $result; # => Anything you like.
?>
<?php // begin with a PHP open tag.
echo "Hello World\n";
print("Hello quickref.me");
?>
PHP run command
$ php hello.php