问题标签 [include-once]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - PHP - variable inclusion not working with include_once inside a namespace
I'm modelling a login page using different schemas (basic username & password combination and another schema using a Yubikey, for now).
My controller looks like this:
The authentication schema looks like this:
The problem I have is include_once()
is not working for me, as the $data
variable isn't really seen neither by the authentication schema nor the opposite (the document namespace seeing any content coming from the authentication schema on inclusion).
However, if I use include()
it works. Maybe the problem lies within the use of a namespace and including external content. I never use the include()
function as I always like to check if the script is already included, even if it has bit of a performance penalty for the extra check.
Maybe I'm not fully understanding how namespaces work in PHP or I did something weird with the array_merge_recursive()
function, but the more I look at the code, the less I find about something potentially wrong and I feel a bit lost.
Can anyone help me figuring this?
php - include_once 在一个页面中有效,但在其他页面中无效,display_error 没有错误
编辑:我正在使用引导程序编辑:当我在actualites.php(文件结尾)中包含底部和页脚时,它可以工作。
我正在建设一个网站,我想通过 url 包含一个内容。所以我有 :
当我访问 url domain-name/apropos 时,出现了 bottom.php 和 footer.php。但随后我访问了 domain-name/actualites,没有出现底部和页脚。
这是错误日志文件的内容:
php - I am using include_once but still getting Cannot redeclare. I know the function exists, that is why I'm using include_once
Ok I am trying to modify some code in a WP Plugin. The plugin declares a file for this:
So I created a file in the above directory called auto_overwrite.php and included the function I wanted to change.
The problem I am having is that I still get the error:
Fatal error: Cannot redeclare listing_tabs() (previously declared in....
I thought the idea of include_once was that is would not include functions that are already defined.
The other function is in a file named meta_boxes.php and it too is called via
I am relatively new to PHP so maybe I'm missing something, any help is greatly appreciated. Thanks!
EDIT: From answers below I see that I cant just call out the function as include_once only limits that specific file from being loaded more than once. Basically I am trying to modify a function specified downstream from this file. Is it possible to do this?
php - PHP - `require_once` 构造如何执行代码?
当我打电话时,我想知道以下哪一项是更好的方法require_once(file.php)
:
file.php
或者
file.php
我很想知道使用其中任何一个是否会在执行过程中导致任何类型的问题。
php - 两次对 include_once 相同文件的 PHP 警告
尝试两次包含同一文件时收到 PHP 警告是正常的。
第一个 include_once 正确加载 PHP 文件。具有相同文件的第二个 include_once 显然给了我一个错误。
我的问题是为什么当文件明确存在时我会得到 a"Warning: include_once(../../config.php): failed to open stream: No such file or directory in ..."
和 a 。"Warning: include_once(): Failed opening ..."
我只是好奇为什么 PHP 不会告诉我“文件已包含”之类的东西,而是说文件不存在。
我的结构:我有一个使用 jQuery .load() 进行内部导航的页面。
初始页面加载如下:
header.php 包含一个 include_once 到 ../config.php 用于服务器配置。
components/activity_feed.php 还包含一个 include_once 到 ../../config.php,因此当通过 .load() 请求 components/my_textbooks.php 时,会加载配置文件并在提供服务之前呈现页面。
php - 从不同的 include_once 文件调用函数时出错?
我有这样的结构:
main.php
包含一次
func1.php
包含一次
func2.php
这两个文件都include
在里面main.php
。
当我function switchboard()
从func1.php
内部调用 a 时,出现以下错误finc2.php
。
第 16 行是我从func1.php
内部调用函数的地方func2.php
—
switchboard() {}
。include
除了ing func1.php
inside有没有办法解决这个问题func2.php
?
func2.php
函数1.php
php - include_once 无法打开流和警告:include_once(): Failed opening.for 包含 (include_path='.:/usr/share/pear:/usr/share/php')
我得到低于错误。我已经尝试过使用dir、document root、require_once 和 require。
我在 Live Server 中遇到此错误。
先感谢您。
php - 在 shell 脚本中使用时 include_once 不起作用
我正在使用./first.sh 之类的 shell 脚本运行 php 文件
在 first.sh 我正在使用以下命令运行一个 php 文件
在 cron 文件下我有这个代码
当我执行 .sh 文件时,我只收到第一封电子邮件,而没有收到第二封电子邮件。在第二封电子邮件下方,我编写了更多代码来获取 wordpress 帖子,但无法正常工作。如果我使用域 url 在浏览器中点击 cron.php,它工作得非常好。
我已经测试了很多其他的 stackoverflow 答案,但没有什么对我有用。
请帮我。
php - include_once():打开流失败:没有这样的文件或目录 - PHP
我试图在 php 中制作一个简单的注册系统。我有一个名为 Admin(在控制器文件夹内)的类,它扩展了 DBConnection.php 类。Admin 类有一个注册方法,可以让广告注册,但有问题。'include_once' 发生错误,错误提示'Warning: include_once(../Database/DBConnection.php): failed to open stream: No such file or directory in C:\xampp\htdocs\WoodlandsAway\controller\Admin.php on第 15 行-----''警告:include_once(): 无法打开'../Database/DBConnection.php' 以包含在 C:\xampp\htdocs 中(include_path='C:\xampp\php\PEAR') \WoodlandsAway\controller\Admin.php 在第 15 行-----''致命错误:第 17 行的 C:\xampp\htdocs\WoodlandsAway\controller\Admin.php 中找不到类 'DBConnection''
这是我的 include_once 代码
--DBConnection.php
}
和 Admin.php
wordpress - PHP:使用 include_once 函数时出错。未能打开“mysiteURL”以供包含
我从未使用过 PHP,只需要它来构建我的 WordPress 网站并安装主题。
每次我在 wp-admin 下打开任何页面时,都会收到警告:
警告:include_once():在 /myURL/public_html/ 中打开 '/myURL/public_html/wp-content/plugins/dsidxpress/admin.php' 以包含 (include_path='.:/usr/local/php56/pear') 失败wp-content/plugins/dsidxpress123/dsidxpress.php 在第 90 行
打开 .php 时,我在第 90 行看到以下代码:
按照说明更改后:
我收到新错误:
我究竟需要如何改变它?