class constant in php

technical talkiess
0

 1) canot redeclear

2) it is used to create some const variable 

3) const keyword  define a class 

4) outside use a varable ::

classname :: variable name 


ex


<!DOCTYPE html>

<html>

<body>


<?php

class vishal{

const name = "vishal usrate 121212 1212";


}

echo vishal::name;

?>


</body>

</html>



inside use 

ex:- 

<!DOCTYPE html>
<html>
<body>

<?php
class vishal{
const name = "Hello .";
function sayhellovishal(){
echo self::name . "vishal usrate";
}

}
$google = new vishal();

echo $google->sayhellovishal(); 

?>

</body>
</html>

Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)