这种写法的人当时是不是吸毒了才这么写
感觉是一种的抽风的写法,也可能是吸毒了太兴粪的写法,不知为了啥。很多人就是不喜欢用常规出牌,总是在那里搞手银的事,这样能升华到那个境界吗
回复讨论(解决方案)
原生的shopnc好像不是这样写的,可能是后来加上吧。
很正常,后补的锁
很正常,后补的锁
此锁何义?
意义在于你不执行它的一段隐藏代码(用于那个常量的定义以其他)就无法让程序执行
意义在于你不执行它的一段隐藏代码(用于那个常量的定义以其他)就无法让程序执行
从原理上说不通
理论上程序都是写好的,才发布。
我觉得没必要加上那么一段代码,又不是用户会随意访问代码,改变代码流程,我觉得完全没必要做这个判断。
理论上程序都是写好的,才发布。
我觉得没必要加上那么一段代码,又不是用户会随意访问代码,改变代码流程,我觉得完全没必要做这个判断。
这里不是有没有必要的问题,而是语法错语的问题,当然这是我目前理解,也是发这帖的原因,都语法错误了,还谈啥?
当然也可能没有错误,不过PHP手册上说的这个return的用法是在函数中,而这里的return没有用在函数中,所以错误!
我希望大家谈谈这个,而不是啥这里这么玩必不必要,再重申一遍, 这里是不是语法错误!!!!!!!!!!!!!!!!
这种写法主要是用于配置文件, 在外面可以这样写 $redisConfig = include('config.inc.php‘); 外面可以接收return的值
第一行是控制入口, 避免外部直接访问该文件
<?phpdefined('InShopNC') or exit('Access Invalid!');return $config;
怎么会是语法错呢?
defined('InShopNC') or exit('Access Invalid!');
是说,如果常量 InShopNC 没有定义,就退出程序并显示 Access Invalid!
否则 返回变量 $config
显然这个程序不能被直接访问,不然只会输出 Access Invalid!
只有在定义了常量 InShopNC 的程序链用 $x = include('config/config.ini.php'); 才能获取到已经定义过的变量 $config 的值
通常 config.ini.php 是用来定义系统初值的地方,而作者却没有这样做,显然是出于某种原因在别处定义了。zy205817 不也说 原生的shopnc好像不是这样写的 吗?
所以我说是:后补的锁
php 中的 return 可以放在任何地方,如果在函数或方法中就是结束当前函数或方法并返回值
如果在函数或方法外,就是结束当前程序文件并返回值
如果你的教科书中没有提及这一点,那么请将此书丢进茅厕里(茅厕还嫌他臭)
手册中明确的说到
如果在一个函数中调用 return 语句,将立即结束此函数的执行并将它的参数作为函数的值返回。 return 也会终止 eval() 语句或者脚本文件的执行。
下面还有很多,我不一一复制了,自己去看
return语句的妙用还真不少
defined('InShopNC') or exit('Access Invalid!');
return $config;
就是有定义过InShopNC的时候,才可以访问 $config;
如果没定义过, 后面or exit('Access Invalid!'); 就已经退出了,不会执行 return $config
所以这个文件如果直接访问是会显示Access Invalid的。
必须是由其他已经定义了InShopNc的页面才可以调用。
defined('InShopNC') or exit('Access Invalid!');
学习了 这也是一种文件权限的妙用
http://php.net/manual/zh/function.return.php
http://php.net/manual/zh/function.return.php
手册里面写了,如果是include 就返回,有什么问题,为什么会有语法错误?

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



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-

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.

Alipay PHP...

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

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

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

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,
