php多次引用出错
以前没有这个问题,php升级到5.4出现这个问题
config.php中代码
<code><?php define('host','localhost'); define('username','root'); define('password','root'); define('database','daan'); ?></code>
connect.php中代码
<code><?php require_once 'config.php'; $mysqli = new mysqli(host,username,password,database); if($mysqli->connect_error) { die('Connect Error:'.$mysqli->connect_error); } $mysqli->set_charset('utf8'); ?></code>
index.php中的代码
<code><?php require_once 'connect.php'; ?></code>
接下来问题来了,如果我在index.php
中单单引入connect.php
,php报错,提示我host username password datebase
这几个常量没有定义
但如果这样
<code><?php require_once 'config.php'; require_once 'connect.php'; ?></code>
就正常了,请问这是怎么回事,如何解决
回复内容:
以前没有这个问题,php升级到5.4出现这个问题
config.php中代码
<code><?php define('host','localhost'); define('username','root'); define('password','root'); define('database','daan'); ?></code>
connect.php中代码
<code><?php require_once 'config.php'; $mysqli = new mysqli(host,username,password,database); if($mysqli->connect_error) { die('Connect Error:'.$mysqli->connect_error); } $mysqli->set_charset('utf8'); ?></code>
index.php中的代码
<code><?php require_once 'connect.php'; ?></code>
接下来问题来了,如果我在index.php
中单单引入connect.php
,php报错,提示我host username password datebase
这几个常量没有定义
但如果这样
<code><?php require_once 'config.php'; require_once 'connect.php'; ?></code>
就正常了,请问这是怎么回事,如何解决
看下这个应该对你有帮助,在回家的路上没法码字
http://m.111cn.net/art-42982.htm
试试将定义的常量名改成大写的试试吧
new mysqli(host,username,password,database);
new mysqli($host,$username,$password,$database);
懂了吗?

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

PHP 8.4 带来了多项新功能、安全性改进和性能改进,同时弃用和删除了大量功能。 本指南介绍了如何在 Ubuntu、Debian 或其衍生版本上安装 PHP 8.4 或升级到 PHP 8.4

CakePHP 是 PHP 的开源框架。它的目的是使应用程序的开发、部署和维护变得更加容易。 CakePHP 基于类似 MVC 的架构,功能强大且易于掌握。模型、视图和控制器 gu

Visual Studio Code,也称为 VS Code,是一个免费的源代码编辑器 - 或集成开发环境 (IDE) - 可用于所有主要操作系统。 VS Code 拥有针对多种编程语言的大量扩展,可以轻松编写
