doddsey_65 Posted September 29, 2010 Share Posted September 29, 2010 Hi, i have a class which i am writing(just a small test) which is supposed to create a label for a form but nothing is showing up. Here is the html part: $frobj=new asf_form(); $frobj->form_label('Username'); and here is the class code: function form_label($label='') { if($label == '') { return false; } else { return '<label for='.$label.'>'.$label; } } Have i done something wrong? Link to comment https://forums.phpfreaks.com/topic/214769-small-class-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 29, 2010 Share Posted September 29, 2010 What are you doing with the value that $frobj->form_label('Username'); returns? Link to comment https://forums.phpfreaks.com/topic/214769-small-class-help/#findComment-1117362 Share on other sites More sharing options...
doddsey_65 Posted September 29, 2010 Author Share Posted September 29, 2010 i wanted to print it on the screen. so the output would be <label for='username'>Username Am i going the wrong way about this? Link to comment https://forums.phpfreaks.com/topic/214769-small-class-help/#findComment-1117364 Share on other sites More sharing options...
PFMaBiSmAd Posted September 29, 2010 Share Posted September 29, 2010 I don't see a print or an echo statement any where in your code (php only does what your code tells it to do.) You are also not using the value that is returned when you call $frobj->form_label('Username');, so that is simply being discarded. Link to comment https://forums.phpfreaks.com/topic/214769-small-class-help/#findComment-1117371 Share on other sites More sharing options...
doddsey_65 Posted September 29, 2010 Author Share Posted September 29, 2010 thanks for the reply. I have tried print rather than return and it works fine. Link to comment https://forums.phpfreaks.com/topic/214769-small-class-help/#findComment-1117372 Share on other sites More sharing options...
rondog Posted September 29, 2010 Share Posted September 29, 2010 thanks for the reply. I have tried print rather than return and it works fine. PFMaBiSmAd meant how are you outputting $frobj You can leave your function do the return, but you need to: echo $frobj Link to comment https://forums.phpfreaks.com/topic/214769-small-class-help/#findComment-1117381 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.