Jump to content

Creating HTML helper, need help!


spaze

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.