MediaSvcsUnlimited Posted June 3, 2016 Share Posted June 3, 2016 Hi, when you have a call to undefined function error, that usually means either you misspelled the function name or the function file isn't attached to the page, right? Can someone help me understand why I'm getting that error? The function names are spelled the same and the function file is attached so I'm not understanding what 's wrong. <php require_once('functions.php'); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Untitled Document</title> <meta name="keywords" content=""> <meta name="description" content=""> <link rel = "stylesheet" href = "Bixler.css"> <style type="text/css"> </style> </head> <body> <?php headerInfo();?> <article> </article> <aside> </aside> <footer> <div id="contactInfo"> Bixler Insurance <br/> 1043 South 13th St. <br /> Decatur, IN 46733<br /> Phone: (260)-724-3438 </div> <div id="eocialMedia"> social media icons </div> <div id="servicesList"> list of services </div> </footer> </body> </html> <?php function headerInfo() { <<<HEREDOC <header> <nav> <ul> <li><a href="#">Home</a></li> <li><a href="#">About Us</a> <ul> <li><a href="#">Agents</a></li> <li><a href="#">Locations</a></li> </ul> <li><!--end of about us menu list --> <li><a href="#">Services</a></li> <li><a href="services.php" tabindex="3" accesskey="S">Services</a></li> <li><a href="quote.php" tabindex="4" accesskey="Q">Get A Quote</a></li> <li><a href="contact.php" tabindex="5" accesskey="C">Contact</a></li> </ul> </nav> <figure id="logo"> <img src="assets/bixlerlogo.png" width="304" height="88" alt=""/> </figure> <h3>Service Beyond The Contract </h3> </header> HEREDOC; /*end of headerInfo function */ /*start of footerInfo function */ function footerInfo() { <<<HEREDOC <footer> <div id="contactInfo"> Bixler Insurance <br/> 1043 South 13th St. <br /> Decatur, IN 46733<br /> Phone: (260)-724-3438 </div> <div id="eocialMedia"> social media icons </div> <div id="servicesList"> list of services </div> </footer> } HEREDOC; /*end of footerInfo function */ ?> Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/ Share on other sites More sharing options...
gizmola Posted June 3, 2016 Share Posted June 3, 2016 You should be getting a parsing error from the look of it, because your functions are not ended properly. function_name() { //code } In both cases your HEREDOC closing is outside of the end of the function. Furthermore HEREDOCS work like so: $var = <<<HEREDOC .... HEREDOC; echo $var; Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533396 Share on other sites More sharing options...
MediaSvcsUnlimited Posted June 3, 2016 Author Share Posted June 3, 2016 (edited) I think I see what you mean, but I'm still getting a call to undefined function headerInfo() function headerInfo() { <<<HEREDOC <header> <nav> <ul> <li><a href="#">Home</a></li> <li><a href="#">About Us</a> <ul> <li><a href="#">Agents</a></li> <li><a href="#">Locations</a></li> </ul> <li><!--end of about us menu list --> <li><a href="#">Services</a></li> <li><a href="services.php" tabindex="3" accesskey="S">Services</a></li> <li><a href="quote.php" tabindex="4" accesskey="Q">Get A Quote</a></li> <li><a href="contact.php" tabindex="5" accesskey="C">Contact</a></li> </ul> </nav> <figure id="logo"> <img src="assets/bixlerlogo.png" width="304" height="88" alt=""/> </figure> <h3>Service Beyond The Contract </h3> </header> HEREDOC; } Edited June 3, 2016 by MediaSvcsUnlimited Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533397 Share on other sites More sharing options...
Jacques1 Posted June 3, 2016 Share Posted June 3, 2016 The PHP tag in the main script around the include statement is malformed: <php Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533398 Share on other sites More sharing options...
MediaSvcsUnlimited Posted June 3, 2016 Author Share Posted June 3, 2016 First, I am so sorry. That was a very stupid mistake on my end. I corrected that and now I'm getting a blank page. Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533400 Share on other sites More sharing options...
Jacques1 Posted June 3, 2016 Share Posted June 3, 2016 Then there's still another issue, maybe a syntax error, maybe something else. Turn your error reporting all the way up and make PHP display errors (this isn't your production server, right?). What does the script say now? Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533401 Share on other sites More sharing options...
benanamen Posted June 3, 2016 Share Posted June 3, 2016 One cause of a blank page is using short tags when short tags are not enabled. Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533403 Share on other sites More sharing options...
MediaSvcsUnlimited Posted June 4, 2016 Author Share Posted June 4, 2016 I added these two lines and still getting a blank page. ini_set('display_errors', 1); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533422 Share on other sites More sharing options...
Jacques1 Posted June 4, 2016 Share Posted June 4, 2016 You need to do it in the php.ini file, not at runtime. The runtime configuration doesn't help you one bit when the error happens before that (e. g. due to syntax problems). Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533423 Share on other sites More sharing options...
ginerjm Posted June 5, 2016 Share Posted June 5, 2016 Not to dispute the good advice that Jacques provided, your setting is incorrect. The value s/b "-1" not "1". Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533438 Share on other sites More sharing options...
Jacques1 Posted June 5, 2016 Share Posted June 5, 2016 The values are correct. display_errors must be 1, error_reporting must be E_ALL. E_ALL can optionally be replaced with -1, but this is an obsolete workaround for early PHP versions where E_ALL didn't actually mean “all errors”. Since PHP 5.4, E_ALL does exactly what it says. Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533439 Share on other sites More sharing options...
MediaSvcsUnlimited Posted June 5, 2016 Author Share Posted June 5, 2016 I don't understand this, but PHP wanted return <<<HEREDOC not echo <<<HEREDOC Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533441 Share on other sites More sharing options...
kicken Posted June 5, 2016 Share Posted June 5, 2016 You need echo or return. Such as: <?php function headerInfo(){ return <<<HEREDOC ... HEREDOC; } ?> ... <?php echo headerInfo(); ?> or <?php function headerInfo(){ echo <<<HEREDOC ... HEREDOC; } ?> ... <?php headerInfo(); ?> Your posts up until now included neither. Note that you don't need to use a HEREDOC at all. You can just exit PHP mode, dump your HTML, then re-enter PHP mode and end the function. I personally find that to be cleaner when dealing with large chunks of HTML, and it sometimes works better with editors tools. <?php function headerInfo(){ ?> ... html here ... <?php } /* End function headerInfo */ ?> Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533443 Share on other sites More sharing options...
ginerjm Posted June 6, 2016 Share Posted June 6, 2016 Actually I prefer the heredocs method for any html over a couple of lines. Makes it easy to output html code and readily accepts php vars with no tags needed! My preferred format (for readability) is the following: $code=<<<heredocs ... .. ... heredocs; echo $code; No confusion there - everyone knows exactly what is going on. Quote Link to comment https://forums.phpfreaks.com/topic/301294-call-to-undefine-function/#findComment-1533444 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.