require-once

PHP and some global variables

岁酱吖の 提交于 2019-12-25 11:35:11
问题 require_once'modules/logger.php'; $Logger = new Logger(); require_once 'templates/list.php'; $Templates = new templatesList(); require_once 'widgets/list.php'; $Widgets = new widgetsList(); I use $Logger in templates/list.php and in widgets/list.php . $Templates I use in /widgets/list.php . The code above throws this error: Notice: Undefined variable: Logger in .../templates/list.php on line 99 Fatal error: Call to a member function toLog() on a non-object in .../templates/list.php on line 99

PHP and some global variables

亡梦爱人 提交于 2019-12-25 11:35:09
问题 require_once'modules/logger.php'; $Logger = new Logger(); require_once 'templates/list.php'; $Templates = new templatesList(); require_once 'widgets/list.php'; $Widgets = new widgetsList(); I use $Logger in templates/list.php and in widgets/list.php . $Templates I use in /widgets/list.php . The code above throws this error: Notice: Undefined variable: Logger in .../templates/list.php on line 99 Fatal error: Call to a member function toLog() on a non-object in .../templates/list.php on line 99

Refactoring require_once file in a project

我怕爱的太早我们不能终老 提交于 2019-12-25 03:15:38
问题 I'm a beginner in PHP. And i'm working on project with this directories hierarchy : model , control , view and helper folders are in my project folder Now i'm trying to write a file init.php and require_once it in each of control and model files, here's my init.php <?php $current_dir = basename(getcwd()); $model_dir = "model"; $helper_dir = "helper"; function require_helper(){ $handle = opendir("../{$helper_dir}"); while($file = readdir($handle)){ if($file != "." && $file != ".."){ require

Joomla - PHP error message

廉价感情. 提交于 2019-12-24 13:22:08
问题 Latest : I've managed to download all files properly this time, but I get this message when I'm trying to import my sql file: The new host has a max limit of 51,200 KiB, my sql file is only 12.5MB and 3.0 MB when zipped. If I upload it as a zip file, it says Script timeout passed, if you want to finish import, please resubmit same file and import will resume. Or it displays: #1044 - Access denied for user 'a9806073_blurb'@'localhost' to database '1487929_blurb' However, if I upload it purely

include, require and relative paths

和自甴很熟 提交于 2019-12-23 20:52:09
问题 I'm not sure why I always have some many problems with this. Anyways this is the path to the file I want to require /var/www/vhosts/mysite.com/htdocs/Classes/DBConnection.php This is the path to the file that has the require statement /var/www/vhosts/mysite.com/htdocs/Classes/Forecast/MyFile.php and this is the require statement in MyFile.php require_once '../DBConnection.php'; I keep getting the "failed to open stream" error. It works fine if I put in an absolute path. Does anyone see the

Call PHP document with SSH includes get variable

落花浮王杯 提交于 2019-12-23 04:29:35
问题 I have the following in a PHP document I'm calling from a cron job. if (is_file($docRoot . $row['cron_action_script_path'])) { system("php " . $docRoot . $row['cron_action_script_path'] . $row['params']); } However, I'm getting the error Could not open input file: /path/to/file.php?params=1 But I am getting past the if statement is_file('/path/to/file.php') So it looks like there's a problem with including get variables on SHH calls to PHP document. Is there anyway around this? I need to be

PHP error: open_basedir restriction in effect

余生颓废 提交于 2019-12-23 02:48:14
问题 I using this Yubico authentication PHP class: https://github.com/Yubico/php-yubico. I create php file test.php with this code: <?php require_once 'Auth/Yubico.php'; $otp = "ccbbddeertkrctjkkcglfndnlihhnvekchkcctif"; # Generate a new id+key from https://api.yubico.com/get-api-key/ $yubi = new Auth_Yubico('42', 'FOOBAR='); $auth = $yubi->verify($otp); if (PEAR::isError($auth)) { print "<p>Authentication failed: " . $auth->getMessage(); print "<p>Debug output from server: " . $yubi-

require_once to global scope within a function

那年仲夏 提交于 2019-12-19 05:18:39
问题 It seems that if require_once is called within function, the included file doesn't extend the global variable scope. How to require_once a file to global scope from within a function? What I'm trying to do is some dynamic module loader: function projects_init() { ... foreach ($projects as $p) { require_once($p['PHPFile']); $init_func = $p['init']; if ($init_func) $init_func(); } } If it is not possible to use require_once that way, what is the simplest solution for this? (Please no heavy

How to know if php script is called via require_once()?

心不动则不痛 提交于 2019-12-19 04:14:06
问题 My webapp has a buch of modules. Each module has a 'main' php script which loads submodules based on a query sent to the main module: //file: clientes.php //check for valid user... //import CSS and JS... switch( $_GET["action"] ) { case "lista" : require_once("clientes.lista.php"); break; case "listaDeudores" : require_once("clientes.listaDeudores.php"); break; case "nuevo" : require_once("clientes.nuevo.php"); break; case "detalles" : require_once("clientes.detalles.php"); break; case

How can I tune the PHP realpath cache?

谁说胖子不能爱 提交于 2019-12-18 12:37:04
问题 Recent versions of PHP have a cache of filenames for knowing the real path of files, and require_once() and include_once() can take advantage of it. There's a value you can set in your php.ini to set the size of the cache, but I have no idea how to tell what the size should be. The default value is 16k, but I see no way of telling how much of that cache we're using. The docs are vague: Determines the size of the realpath cache to be used by PHP. This value should be increased on systems where