Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. <?php //php 7.0.8
  2.  
  3. class Hello {
  4. public $var1;
  5. public $var2;
  6.  
  7. function __construct( $x, $y ) {
  8. $this->var1 = $x;
  9. $this->var2 = $y;
  10. }
  11.  
  12. function printvar1() {
  13. echo $this->var1. "\n";
  14. }
  15.  
  16. function retvar1() {
  17. return $this->var1;
  18. }
  19.  
  20. function printvar2() {
  21. echo $this->var2. "\n";
  22. }
  23.  
  24. function retvar2() {
  25. return $this->var2;
  26. }
  27.  
  28. }
  29.  
  30. $hello = new Hello( 13, 37 );
  31. $hello->printvar1();
  32. $a = $hello->retvar1();
  33. echo $a. "\n";
  34. $hello->printvar2();
  35. $b = $hello->retvar2();
  36. echo $b. "\n";
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement