Page 1 of 1

Cant find HTML

Posted: Thu May 24, 2007 1:58 pm
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

Posted: Thu May 24, 2007 3:50 pm
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.

Descriptive subjects

Posted: Thu May 24, 2007 6:05 pm
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.

Posted: Fri May 25, 2007 10:19 am
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