PHP Fatal error: Call to undefined function?

29,555

Call to undefined function error clearly shows that its not getting your function where you have defined. Reason is you are attaching full path of settings.php file with http.

You need to include settings.php file without http path at the top of 'index.php' and make sure settings.php file is located in your project only. If it is located at the same folder with index.php, then simply include like below.

<?php include __DIR__.'/settings.php'; ?> 

If your settings.php file is located in some other folder then you can use $_SERVER['DOCUMENT_ROOT'] to include that file like below:

<?php 
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/yourpath/settings.php";
include_once($path);
Share:
29,555

Related videos on Youtube

Nick Leeman
Author by

Nick Leeman

Updated on January 21, 2022

Comments

  • Nick Leeman
    Nick Leeman over 2 years

    So i have a problem with my website when im hosting it on my webhost. i get this error:

    PHP Fatal error:  Call to undefined function getSkillIcons()
    

    The weird thing is that locally(Xampp) it works just fine.

    This is how i included the function(in index.php):

    <?php include 'http://sub.website.com/incl/Settings.php'; ?>
    

    this is where i call it (index.php):

    <div class="panel-body" style="text-align:center">
    <?php getSkillIcons(explode(',', skills)); ?>
    </div>
    

    This how i defined skills (settings.php)

    define("skills", "Test1,Test2,Test3,Test4");
    

    this is the function itself: (settings.php)

    function getSkillIcons($skills) {
        echo '<a href="?skill=Overall" title="Overall" data-toggle="tooltip"            data-placement="top"><img src="http://sub.website.com/incl/img/skill_icons/Overall-icon.png" class="skill-icon"></a>';
        for ($i = 0; $i < count($skills); $i++) {
            $tooltip = 'title="'.$skills[$i].'" data-toggle="tooltip" data-placement="top"';
            echo '<a href="?skill='.$skills[$i].'" '.$tooltip.'><img src="http://sub.website.com/incl/img/skill_icons/'.$skills[$i].'-icon.png" class="skill-icon"></a>';
        }