关于用ini_set修改配置项的问题
首先我需要用ini_set('allow_url_include', "1");来修改下配置项来使得页面可以允许url包含,但是我这么写了之后还是没起作用,请问这个是为什么?
再就是我开启这个实在是我想不到好的方法了,只能暂时开启下回头然后再考虑好的方法,那我想问下开启这一项会对安全性有造成影响吗?或者这个选项一般是开启好些还是最好不要开启??
回复讨论(解决方案)
allow_url_include 这个设置要求 allow_url_fopen 也要开启。
allow_url_include 不能在代码中设置。只能在 php.ini 中设置
allow_url_include 的本意是通过统一资源定位来实现代码资源的共享,有如 html 的 src=xxx.js
但是对方服务器并不知道 http://host/code.php 是源于 include 的,所以美好愿望并不能实现
这能做到 include 非 php 文件中的 php 代码
如果只是为了获取对方程序的执行结果,那么 file_get_contents 也就可以了
allow_url_include 这个设置要求 allow_url_fopen 也要开启。
那个我是开着的,但是还是不行
allow_url_include 不能在代码中设置。只能在 php.ini 中设置
allow_url_include 的本意是通过统一资源定位来实现代码资源的共享,有如 html 的 src=xxx.js
但是对方服务器并不知道 http://host/code.php 是源于 include 的,所以美好愿望并不能实现
这能做到 include 非 php 文件中的 php 代码
如果只是为了获取对方程序的执行结果,那么 file_get_contents 也就可以了
嗯,一般情况下那个是可以的,我开始也尝试了那种方法,但是还是不行,没有达到我想要的效果。现在我解决了,但是这个方法比较那个什么,我也不知道怎么讲,我把我想要的效果敲在楼下,你帮我看看我的实现方法或者你帮我看看有什么好的方法能够实现
那首先,我要实现一套MVC模式的系统,然后有一个入口文件index.php,一个主类文件Myth.class,一个模板编译类文件,MythTemplate.class,然后我的控制器文件是一个类,拿默认控制器来说是这样的:
class IndexAction extnnds MythTemplate {
public function index() {
$this->assign('var1', 'value1');
$_obj = Myth::Action('public/header', $this);
}
}
那个调用是调用模板类的方法想模板中注册变量。。然后模板编译之后生成一个.php文件,那我直接include找个php文件这样的话就可以访问,这样是没问题的。
那问题是什么呢?就是因为一般网页中头部(header)和底部(footer)是公共的所以需要单独拿出来然后在index.html的模板中引入header.html和footer.html,那我就在模板中子定义一个标签来实现包含这个header.html的文件,那因为我的页面的访问地址形式是这样的:
www.fantan.com/index/index.html
这里是访问首页,那在首页中要包含header.html并且通过header.html的控制器:
class PublicAction extends MythTemplate {
public function header() {
$this->assign('var2', 'value2');
}
}
来注册header.html模板中的变量的话就需要包含这个页面,这样的话就出现了我讲的那个问题,因为如果通过改变php.ini文件的那个选项的话就其实就可以实现了,但是我总觉得这种不太好,所以我就没用了后面,那我现在使用的方法是在Myth类中增加一个静态的方法:
class Myth{
public static functin Action('public/header', $_that) {
$_obj = new public();
$_obj->_data = &$_that;
}
}
这里$_data数组是模板类中保存模板变量的数组,这样把两个不同对象中的$_data数组通过关联达到数据一致的效果,但是这个访问唯一不好的就是这里:
$_obj = Myth::Action('public/header', $this);
就是你要调用必须显式的传递$this,我觉得这里可以不用传的,但是我又想不到好点的方法。。。。
不知道说清楚没,但是现在我的问题已经不是开始的那个,变成了刚刚提到的那个就是:不显式的传递$this,但是可以在Action方法中获取调用这个方法的方法所在类的对象怎么获取?
allow_url_include 不能在代码中设置。只能在 php.ini 中设置
allow_url_include 的本意是通过统一资源定位来实现代码资源的共享,有如 html 的 src=xxx.js
但是对方服务器并不知道 http://host/code.php 是源于 include 的,所以美好愿望并不能实现
这能做到 include 非 php 文件中的 php 代码
如果只是为了获取对方程序的执行结果,那么 file_get_contents 也就可以了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio
