eldan88 Posted April 18, 2014 Share Posted April 18, 2014 Hey Guys. I am new to working with static properties. I have defined a satic property and trying to echo it out in a input field string. But it won't echo out. Does any one know why?? Below is my code. Thanks in advance class html_generator extends validation { public static $input_class; public function __construct() { self::$input_class = (isIphone()) ? "mobile_text_field" : ""; } //Input string I i am trying to echo out the input_class "<input type='text' id='name' name='name' class='{html_generator::$input_class}' >" Quote Link to comment Share on other sites More sharing options...
.josh Posted April 18, 2014 Share Posted April 18, 2014 you need to remove the $ in front of $input_class Quote Link to comment Share on other sites More sharing options...
eldan88 Posted April 18, 2014 Author Share Posted April 18, 2014 Oh okay. Does that only apply for strings? Because I have another static property where is put a $ infront of it... for example class::$prop and it worked fine... Quote Link to comment Share on other sites More sharing options...
eldan88 Posted April 18, 2014 Author Share Posted April 18, 2014 .josh. I tried removing the $ and it still isn't functioning properly. I even went ahead and debugged my code... Quote Link to comment Share on other sites More sharing options...
eldan88 Posted April 18, 2014 Author Share Posted April 18, 2014 The only way it works is by concatenating like so.... "<input type='text' id='name' name='name' class=". html_generator::$input_class_test . " value='{$post_values->name}' >" Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted April 18, 2014 Share Posted April 18, 2014 Josh was referring to the '$' here: html_generator::$input_class Quote Link to comment 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.