感觉是一种的抽风的写法,也可能是吸毒了太兴粪的写法,不知为了啥。很多人就是不喜欢用常规出牌,总是在那里搞手银的事,这样能升华到那个境界吗
回复讨论(解决方案)
原生的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 就返回,有什么问题,为什么会有语法错误?

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

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.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools