Tuesday, 9 June 2020

how to print text which is stored in object

oop
how to print text which is stored in object
<?php

class Example{
declared class, declared property and write function to display,
public $text = 'welcome to telug computer worlds';
public function display (){
echo '<h2>' .$this -> text. '</h2>';
}
}

$ex = new Example;
declared object
echo $ex -> text;
load that text to ex and print
echo $ex -> display();
load that display output to ex and print that
?>

<?php

class Example{
public $text = 'welcome to telug computer worlds';
public function display (){
echo '<h2>' .$this -> text. '</h2>';
}
}

class AnExample extends Example{
without writng whole code from previous class, simply write extend,  using this we can use the variables
}

$ae = new AnExample;
echo $ae -> text;

echo $ae -> display();

?>
how to print text which is stored in object
<?php

class Example{
public $text = 'welcome to telug computer worlds';
public function display (){
echo '<h2>' .$this -> text. '</h2>';
}
}

$ex = new Example;
echo $ex -> text;
echo $ex -> display();
?>
how to use other class
<?php

class Example{
public $text = 'welcome to telug computer worlds';
public function display (){
echo '<h2>' .$this -> text. '</h2>';
}
}

class AnExample extends Example{
public $string = 'telugu computer world';
public function displayString (){
return '<h1> .$this -> string .'</h1>';
}
}
$ae = new AnExample;
$ae -> displaystring();
?>

class
public
public function
new
class extends
class
public
public function
echo
echo
class
public
public
class extends
public
public function
return
new
how to concatenate variable and html
how to use other class



No comments:

Post a Comment