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
Cant find HTML
Moderator: General Moderators
-
smilesmita
- Forum Commoner
- Posts: 30
- Joined: Thu May 24, 2007 1:52 pm
Cant find HTML
Last edited by smilesmita on Fri May 25, 2007 10:20 am, edited 1 time in total.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
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......generates...this HTML......but if you didn't know PHP you wouldn't be able to ascertain that.
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'));Code: Select all
<ul><li>foo</li><li>bar</li></ul>
Last edited by Ollie Saunders on Fri May 25, 2007 2:41 pm, edited 1 time in total.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Descriptive subjects
Smilesmita, would you mind editing your title to make it a little easier to understand what your post is about?
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.[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.
-
smilesmita
- Forum Commoner
- Posts: 30
- Joined: Thu May 24, 2007 1:52 pm