spaze Posted March 19, 2008 Share Posted March 19, 2008 Hello all! I am developing an HTML helper for my own use and don't know exactly if I am doing the right thing. I have a PHP script that includes a file called "helper.class" which contains class helper. $html = new Helper; $content .= $html->start(); $content .= $html->dotag( "body", array ( "class" => "myclass" ) ); in the Class Helper there is a function called start(). class Helper { function start() { return "<html>"; } } So the above would produce output of: <html> <body class="myclass"> My question is this: Is there a way I could do this with following way: $html = new Helper; $html->start(); $html->dotag( "body", array ( "class" => "myclass" ) ); So in other words, can I call the functions in the class and add the results into a variable without using the $content .= portion? Link to comment https://forums.phpfreaks.com/topic/96875-creating-html-helper-need-help/ Share on other sites More sharing options...
uniflare Posted March 19, 2008 Share Posted March 19, 2008 you could but you would need to tweak the functions to add it to a global or global class variable, eg: class Helper { function start() { return "<html>"; } } would become: class Helper { function start() { Global $content; $content .= "<html>"; } } hope this helps, Link to comment https://forums.phpfreaks.com/topic/96875-creating-html-helper-need-help/#findComment-495749 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.