Parsing the problem of invalid content variables in thinkphp import files_PHP tutorial

WBOY
Release: 2016-07-21 15:05:12
Original
714 people have browsed it

I encountered a problem when using TP to integrate the Alipay account binding function
There is a file config.class.php under the ORM
After direct import(), I found that the variables in it cannot be used, but it is indeed loaded. . (The content is successfully output in config.class.php)
I have been thinking about Baidu for a long time. .
It turns out that I have always known that JS scope ignores that PHP functions also have scope - -
Specific principle:

Copy code The code is as follows:

class b{
function test(){
myImport("a.php");
$testClass = new impClass();
$testClass->test();
echo $a."from b";
}
}
class a{
function funa(){
$InsB = new b();
$InsB->test();
}
}
function myImport($file){
require $file;
echo $a."from myImport";
}
$InsA = new a();
$InsA->funa();
?>
a.php
$a = "a";
class impClass{
function test(){
echo "import success";
}
}
?>

Display:

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327726.htmlTechArticleI ran into a problem when using TP to integrate the Alipay account binding function. There is a file config.class.php under the ORM. Import it directly. () and found that the variables inside cannot be used but they are indeed loaded. . (In conf...
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