print(object)
Posted: Fri Jul 27, 2007 4:47 pm
A co-worker of mine (a more experienced PHP'er, as I am just learning it) had suggested that I use a class to generate the dynamic parts of the page that I need. One such area is the navigation bar, so I will refer to that in my question.
The way he described it is that the class (or object) is a "string" and in the HTML all I would have to do is use the print() directive to generate the HTML needed in that spot. (so I guess it would look something like <div class="nav"> print nav_generator.php </div>)
Coming from more of an application programming background I was thinking that this was simply using a _to_string sort of thing, but he seemed to disagree with me on that. When asked for an example or a better explanation I was simply given a link to the OOP portion of the PHP manual, and I was unable to find an example of this technique within the documentation.
If anyone has any idea of what I am talking about I would love to hear back from you. Currently I am working on just using server side includes and echo-ing out HTML, the class/print() design seems much more elegant.
(Also I believe that he mentioned that drupal uses this technique, if that sheds any light on the situation.
Again. any help would be appreciated.
The way he described it is that the class (or object) is a "string" and in the HTML all I would have to do is use the print() directive to generate the HTML needed in that spot. (so I guess it would look something like <div class="nav"> print nav_generator.php </div>)
Coming from more of an application programming background I was thinking that this was simply using a _to_string sort of thing, but he seemed to disagree with me on that. When asked for an example or a better explanation I was simply given a link to the OOP portion of the PHP manual, and I was unable to find an example of this technique within the documentation.
If anyone has any idea of what I am talking about I would love to hear back from you. Currently I am working on just using server side includes and echo-ing out HTML, the class/print() design seems much more elegant.
(Also I believe that he mentioned that drupal uses this technique, if that sheds any light on the situation.
Again. any help would be appreciated.