Hi all. I'm hoping that one of you could assist me in what may be very obvious to you experienced folks, but what does the 5th line of code saying "head("Home");" do? The include statement already brings up home.php, and I'm not used to a templated website structure. Thanks in advance.

<?
include("include/common.class.php");
include("include/search_form.class.php");
include("include/image.class.php");

head("Home");

include("templates/".template."/home.php");

foot();
?>

Dani AI

Generated

Short answer: that line calls a user-defined function named head and passes the page name as an argument. As and noted, the function is defined in one of the included files (commonly the file named common.class.php) and typically performs the site’s header-related work: set the HTML <title>, emit the doctype and opening <html>/<head> markup, link CSS/JS, output the navigation bar (often marking the active menu item based on the passed name), and possibly start sessions or buffering. A companion function (often named foot) usually closes the tags and includes footer scripts.

Practical checks to see exactly what it does:

  • Search the codebase for the function definition and any wrappers. Example shell commands:

    grep -R --line-number "function head" .
    grep -R --line-number "define('template'" .

    If nothing shows, search for occurrences of head( to locate wrapper functions or aliases. Inspect the include files in the load order (the file names shown in the first post are the best starting points).

Common pitfalls and quick fixes:

  • If PHP raises “Call to undefined function head()”, one of the include files didn’t load or the include order is wrong — use require_once for critical files so failures are obvious.

  • The original snippet uses short open tags (<?) which depend on short_open_tag being enabled; replace them with <?php for portability.

  • For debugging, enable errors:

    ini_set('display_errors', 1);
    error_reporting(E_ALL);
  • If the title or menu name is dynamic, ensure the function sanitizes output (use escaping/encoding) to avoid XSS.

Tying back: ’s suggestion that the parameter marks the “current” menu item is common practice; viewing the head implementation will confirm precisely which responsibilities it has.

Recommended Answers

All 4 Replies

a user defined function,
found in common.class.php

<useless>
head(pagename);
I use 'pagename' to indicate which menu link does nothing,
you cant go to pagename from pagename, the link is just text
</useless>
I'm assuming your author did as well

It calls a function called head() and passes in the string 'Home' as a parameter. It does whatever that function does.

Thank you for your help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.