Cant find HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
smilesmita
Forum Commoner
Posts: 30
Joined: Thu May 24, 2007 1:52 pm

Cant find HTML

Post by smilesmita »

hi there,
i am a newbie in PHP.I am currently reading/urnderstanding code written by my collegue.itt obejct oriented programming in PHP.i used to first work in ASP where i used to first design the page in HTML and then insert my ASP code onto it.
i was trying to look for the HTML coding onto his project but i am not able to find it.All his PHP files are named as class.dispatch.php or class.feature.php[as an example].

now my question to you guys is:

is it that when you use OOP approach you dont need html..Do you use any functions[inbuilt] in php for html coding?? or can you code the design of your page by again creating severla classes??
i am so confused as to where i shud start to understand his code and unfortunately he is on leave so i had to ask this question over the forum.any light in this direction would be really appreciated.

thanks
smita
Last edited by smilesmita on Fri May 25, 2007 10:20 am, edited 1 time in total.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

With high level OO abstraction you can pretty much eliminate HTML from the code base. It is not that HTML is not required it is just that the way it is being created has become non-obvious to someone, like yourself, who isn't familiar with OO or the code your colleague wrote. As a very simple example this code...

Code: Select all

function tag($name, $contents)
{
    if (!strlen($contents)) {
        return '';
    }
    return '<' . $name. '>' . $contents . '</' . $name . '>';
}
function unorderedList(array $items) 
{
    $content = '';
    foreach ($items as $item) {
        $content.= tag('li', $item);
    }
    return tag('ul', $content);
}
echo unorderedList(array('foo', 'bar'));
...generates...this HTML...

Code: Select all

<ul><li>foo</li><li>bar</li></ul>
...but if you didn't know PHP you wouldn't be able to ascertain that.
Last edited by Ollie Saunders on Fri May 25, 2007 2:41 pm, edited 1 time in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Descriptive subjects

Post by RobertGonzalez »

Smilesmita, would you mind editing your title to make it a little easier to understand what your post is about?
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
There is a chance that the developer is using templates of some sort to act as a presentation layer in the code base. Are there any files at all that are named .tpl perhaps? Also, there is a chance that some of the PHP files are actually templates themselves, perhaps saved in a /views/ path of sorts.
smilesmita
Forum Commoner
Posts: 30
Joined: Thu May 24, 2007 1:52 pm

Post by smilesmita »

Thank you guys for the input.While i was reading the code i came across the same form of code which you showed me as example and now i am understanding where the html is comming from!

thanks!

smita
Post Reply