Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php
  2. $name = "adrian";
  3. $array = array(4, 34, $name);
  4. print_r($array);
  5. echo "<br>";
  6. $arrayAsociativa = array('superpoder' => 4, 'edat' => 34, "nombre" => $name);
  7. print_r($arrayAsociativa);
  8. echo "<br>";
  9. echo $array[1];
  10. echo "<br>";
  11. echo $arrayAsociativa['nombre'];
  12.  
  13. echo "<br>";
  14. echo sumar(5, 5);
  15.  
  16. function sumar($n1, $n2) {
  17. return $n1 + $n2;
  18. }
  19.  
  20. echo "<br>";
  21. $person = new persona("pepito", 55);
  22. $person->showInfo();
  23. $person->toString();
  24.  
  25. class persona {
  26.  
  27. private $name = "adrian";
  28. private $age = 23;
  29.  
  30. function __construct($name, $age) {
  31. $this->name = $name;
  32. $this->age = $age;
  33. }
  34.  
  35. public function toString() {
  36. echo "Name: $this->name<br>";
  37. echo "Age: $this->age<br>";
  38. }
  39.  
  40. public function showInfo() {
  41. echo "Name: $this->name<br>";
  42. echo "Age: $this->age<br>";
  43. }
  44.  
  45. }
  46.  
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement