search
HomeBackend DevelopmentPHP Tutorial这样判断不是引用文件?

这样写的三个if句,不是引用文件 吧?我的理解是判断有没有,但不是引用!
如果不是引用的话,那这三个文件中的方法或设置啥的都没有引过来,比如它里面的函数或是变量常量啥的都没有引过来,还是不能用!不知这么理解对吗

if (!@include(dirname(dirname(__FILE__)).'/global.php')) exit('global.php isn\'t exists!');if (!@include(BASE_PATH.'/control/control.php')) exit('control.php isn\'t exists!');if (!@include(BASE_CORE_PATH.'/33hao.php')) exit('33hao.php isn\'t exists!');


回复讨论(解决方案)

是引用,判断有没有,有的话就引用进来了。

如果引用文件失败,则退出

是引用,判断有没有,有的话就引用进来了。


我卡就卡在这里,为啥它同时也是引用呢,这个道理怎么讲?

如果引用文件失败,则退出


可if条件成立也不能把文件引进来啊,因为我的理解它这里是判断真的假的,仅此而已。

为什么呢?
if (!@ include(dirname(dirname(__FILE__)).'/global.php')) exit('global.php isn\'t exists!');
include(dirname(dirname(__FILE__)).'/global.php') 用于引入 global.php 文件,这没有异议吧?
如果失败将返回假,并伴随错误信息。屏蔽掉错误信息后
var_dump(@include('global.php')); //bool(false)

这样还不能理解吗?

为什么呢?
if (!@ include(dirname(dirname(__FILE__)).'/global.php')) exit('global.php isn\'t exists!');
include(dirname(dirname(__FILE__)).'/global.php') 用于引入 global.php 文件,这没有异议吧?
如果失败将返回假,并伴随错误信息。屏蔽掉错误信息后
var_dump(@include('global.php')); //bool(false)

这样还不能理解吗?



为什么呢?
if (!@ include(dirname(dirname(__FILE__)).'/global.php')) exit('global.php isn\'t exists!');
include(dirname(dirname(__FILE__)).'/global.php') 用于引入 global.php 文件,这没有异议吧?
如果失败将返回假,并伴随错误信息。屏蔽掉错误信息后
var_dump(@include('global.php')); //bool(false)

这样还不能理解吗?


没有,我的理解是,这样只能是判断有没有,而不是引用文件。

那就请你动手做以下,以清除错误的想法

IF判断需要执行括号里的运算,include 执行完毕(成功)将返回1,SO

IF判断需要执行括号里的运算,include 执行完毕(成功)将返回1,SO


呵呵,对对,执行完毕,这个解释有道理,明白了。

include就是引用包含的意思啊,可以去看下手册,引用失败就退出。如果只是判断存不存用file_exists()就可以了。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

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-

Build a React App With a Laravel Back End: Part 2, ReactBuild a React App With a Laravel Back End: Part 2, ReactMar 04, 2025 am 09:33 AM

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

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

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.

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

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' =>

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

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

Notifications in LaravelNotifications in LaravelMar 04, 2025 am 09:22 AM

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov

Explain the concept of late static binding in PHP.Explain the concept of late static binding in PHP.Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP Logging: Best Practices for PHP Log AnalysisPHP Logging: Best Practices for PHP Log AnalysisMar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)