Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://youtu.be/I26upu4ZOCI
- ----
- classuser.php
- ----
- <?php
- class User
- {
- public $name;
- public $age;
- public function Describe()
- {
- return $this->name . " tiene " . $this->age . " años de edad";
- }
- }
- ?>
- ----
- classper.php
- ----
- <?php
- class Persona {
- public $nombre;
- public function asignarnombre($nom)
- {
- $this->nombre=$nom;
- }
- public function imprimir()
- {
- echo $this->nombre;
- echo '<br>';
- }
- }
- ?>
- ----
- p1.php
- ----
- <html>
- <head>
- <title>Pruebas</title>
- </head>
- <body>
- <?php
- include 'classper.php';
- error_reporting(E_ALL);
- ini_set("display_errors", 0);
- $per1=new Persona();
- $per1->asignarnombre('Pepe');
- $per1->imprimir();
- echo "<br>";
- echo $per1->$nombre;
- echo "<br>";
- $per2=new Persona();
- $per2->asignarnombre('Ana');
- $per2->imprimir();
- ?>
- </body>
- </html>
- ----
- p2.php
- ----
- <html>
- <head>
- <title>Pruebas</title>
- </head>
- <body>
- <?php
- include 'classuser.php';
- $user = new User();
- $user->name = "Eddie Smith";
- $user->age = 99;
- echo $user->Describe();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement