PHP包括不工作?功能不包括在内 [英] Php include not working? function not being included

查看:106
本文介绍了PHP包括不工作?功能不包括在内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是情况的完整背景:

我最近买了一台新的Mac,我是一名php开发人员,因此我下载了MAMP并开始开发。

p>

首先我注意到我的包含没有被包含,但我通过配置我的 php.ini 来改变它。

例如我有一个名为 functions.php 的文件:

 <?php 
函数doit(){
echodid it;
}
?>

以及包含它的文件,名为index.php

 <?php include(functions.php);度特();?> 

我得到这个错误信息

致命错误:在第4行的index.php中调用未定义函数doit()

因为他们有同样的问题让我解释什么和为什么出问题。

如果你包含一个不在你的目录中的函数(例如c://或file: //),而是包含使用http。 include只能返回文件中回显的内容,但不会显示类似变量或函数的内容。所以总是通过一个目录


包含函数和变量

Here is the full context of the situation:

I recently got a new Mac, I'm a php developer so I downloaded MAMP and started developing.

First I noticed that my includes were not being included, but I changed that by configuring my php.ini.

However now, when I try to include a file with a function it does not recognize the function.

For example I have a file named functions.php:

<?php
function doit(){
    echo "did it";
}
?>

and a file that includes it called index.php

<?php include("functions.php"); doit();?>

and I get this error message

Fatal error: Call to undefined function doit() in index.php on line 4

解决方案

So if anyone ever stumbles on this forum because they are having the same issue let me explain what and why it went wrong.

If you include a function not in your directory(e.g c:// or file://) but instead include using http. The include can only return what was echoed in the file, but something like a variable or function will not be shown. So always include functions and variables through a directory

这篇关于PHP包括不工作?功能不包括在内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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