Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $name = "adrian";
- $array = array(4, 34, $name);
- print_r($array);
- echo "<br>";
- $arrayAsociativa = array('superpoder' => 4, 'edat' => 34, "nombre" => $name);
- print_r($arrayAsociativa);
- echo "<br>";
- echo $array[1];
- echo "<br>";
- echo $arrayAsociativa['nombre'];
- echo "<br>";
- echo sumar(5, 5);
- function sumar($n1, $n2) {
- return $n1 + $n2;
- }
- echo "<br>";
- $person = new persona("pepito", 55);
- $person->showInfo();
- $person->toString();
- class persona {
- private $name = "adrian";
- private $age = 23;
- function __construct($name, $age) {
- $this->name = $name;
- $this->age = $age;
- }
- public function toString() {
- echo "Name: $this->name<br>";
- echo "Age: $this->age<br>";
- }
- public function showInfo() {
- echo "Name: $this->name<br>";
- echo "Age: $this->age<br>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement