Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP not finding function declared in required file
    primarykey
    data
    text
    <p>Recently downloaded some code for a minor open-source project related to a small webgame I play. Trying to access it fails and spits out an error message of:</p> <blockquote> <p>PHP Fatal error: Call to undefined function v() in /Applications/MAMP/htdocs/infocenter/modules/security_mod.php on line 7</p> </blockquote> <p>After searching, I found that the function v() is defined in a file called "system.php" which is required by a file which is required by a file which is required by the "security_mod.php" file that the error occurs in. No errors occur with any of the require calls (and they're all 'require_once', not an 'include').</p> <p>This is the whole of the system.php file:</p> <pre><code>&lt;?php function v($a, $i) { return isset($a[$i]) ? $a[$i] : null; } ?&gt; </code></pre> <p>This is the function in 'security_mod.php' that throws the error (also including the require calls):</p> <pre><code>&lt;?php require_once("settings_mod.php"); require_once("account_mod.php");//this file requires base_mod.php, which requires system.php class SecurityMod { public static function checkLogin() { $name = v($_REQUEST, "acc");//this is the line that causes the error $password = v($_REQUEST, "pwd"); if (!isset($name) || !isset($password)) { return null; } $acc = AccountMod::getAccount($name); if (SettingsMod::USE_ENCRYPTED_PASSWORDS) { if (is_null($acc) || $acc-&gt;getPassword() != md5($password)) { return null; } else return $acc; } else { if (is_null($acc) || $acc-&gt;getPassword() != $password) { return null; } else return $acc; } } ?&gt; </code></pre> <p>I did a little testing, and found out that I can access variables and functions in some of the other required files. All of those are in classes, though, unlike v(). Would that be the reason?</p> <p>EDIT to clarify how 'system.php' is required: 'security_mod.php' has these two <code>require_once</code> calls at the beginning of the file:</p> <pre><code>require_once("settings_mod.php"); require_once("account_mod.php"); </code></pre> <p>'settings_mod.php' is a file containing constants used through the program, and includes no files. 'account_mod.php' has these two <code>require_once</code> calls:</p> <pre><code>require_once("base_mod.php"); require_once("account.php"); </code></pre> <p>'account.php' has a pair of <code>include_once</code> calls that include inconsequential and unrelated files. 'base_mod.php' is the file with the ultimate requirement for 'system.php':</p> <pre><code>require_once("system.php"); require_once("settings_mod.php"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload