Advertisement
linuxyamigos

Untitled

Dec 30th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.35 KB | None | 0 0
  1. <?php
  2.  
  3. class Saludadora
  4. {
  5.     private $nombre;
  6.     private $tratamiento;
  7.    
  8.     function __construct($nombre, $tratamiento = NULL){
  9.         $this->nombre = $nombre;
  10.         $this->tratamiento = $tratamiento;
  11.     }  
  12.    
  13.     function saludar(){
  14.         return "Hola $tratamiento $nombre";
  15.     }
  16.    
  17. }
  18.    
  19. $s = new Saludadora(tratamiento: 'Sr.', nombre: 'Juan');
  20. echo $s->saludar();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement