在PHP中:如何使用include()函数哪个参数是可变的? [英] In PHP :how can I use include() Function which parameter is variable?

查看:91
本文介绍了在PHP中:如何使用include()函数哪个参数是可变的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



但是,当我尝试这样做时,我遇到了一些错误。



代码:

  $ year = $ _ POST ['year']; 

$ month = $ _ POST ['month'];

$ day = $ _ POST ['day'];

包括Event.php?year =。$ year。& month =。$ month。& day =。$ day;

那么,U可以帮助我吗? :)

解决方案

包含文件时,不能传递任何参数。然而,它们继承了当前范围(全局或方法)中的任何变量。



我在猜测你的代码是干什么的,但我认为你可以这样做:



includeEvent.php;


I need to use include Function with variable.

but,when I try to do it I faced some errors .

Code :

$year=$_POST['year'];

$month=$_POST['month'];

$day=$_POST['day'];

include "Event.php?year=".$year."&month=".$month."&day=".$day;

so,can U help me ? : )

解决方案

When you include files, you can't pass them any arguments. However they DO inherit any variables in the current scope (global or method).

I'm guessing at what your code does, but I assume you can just do this:

include "Event.php";

这篇关于在PHP中:如何使用include()函数哪个参数是可变的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆