Jaswinder Posted June 11, 2013 Share Posted June 11, 2013 (edited) hello friends i am new to oops.... what i am trying is put the value of a constant in a variable... but not getting any output code :- <?phpclass visible{ const a='Hello';}class check extends visible{ private $c; public function c() { $this->c=self::a; }}$d=new check;echo $d->c();?> is it possible to inherent a constant ?? Edited June 11, 2013 by Jaswinder Quote Link to comment https://forums.phpfreaks.com/topic/279021-oops-problem/ Share on other sites More sharing options...
Solution Psycho Posted June 11, 2013 Solution Share Posted June 11, 2013 What do you expect to be echo'd? All the method "c" is doing is assigning a value to a variable. It isn't returning anything. Quote Link to comment https://forums.phpfreaks.com/topic/279021-oops-problem/#findComment-1435266 Share on other sites More sharing options...
Jaswinder Posted June 11, 2013 Author Share Posted June 11, 2013 ok ..so this means .. i am not returning the variable in function .. thank you problem solved @ Psycho Quote Link to comment https://forums.phpfreaks.com/topic/279021-oops-problem/#findComment-1435392 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.