Home > Backend Development > PHP Tutorial > 这个return到底咋玩呢

这个return到底咋玩呢

WBOY
Release: 2016-06-23 13:33:46
Original
1078 people have browsed it

一般来说,这玩意放在函数中,或类中的方法里,但是最近发现了一个垃圾这么写的,这里这个return $config;可不是放在函数中了,光秃秃的放在页面中,这是啥回事,这样能玩吗,看到很多教程中没有讲过这种葵花宝典似的玩法啊

<?php// defined('InShopNC') or exit('Access Invalid!');$config = array();$config['shop_site_url'] 		= 'http://192.168.0.10/shop';$config['cms_site_url'] 		= 'http://192.168.0.10/cms';return $config;
Copy after login


回复讨论(解决方案)

比如你的文件名是:config.php
用的时候则是:

$config = include( 'config.php');

楼上说的对,这个就当做配置文件了,其他文件直接引用这个文件时可用。

一个垃圾这么写的。。。
这写法很常见啊!

include还能有返回值的?

很多开源的东西里面都是这样用的  $config = include( 'config.php');

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template