2014-12-22 37 views
0
<?php 
    class SomeClass { 

    public function do_string(){ 
    $this->cacheFile(); 

    $unimportant_code = "unimportant"; 


    $someClass = new SomeClass(); 
    $some_string = $someClass->string; //Retruns 4 
    $some_string = $some_string + 2; 

    $variable = $some_string; //6 
    $this->pass($variable); 
    } 

    public function pass($var){ 
    //Do something with var and get the code I need 
    $variable = $var; 

    require_once("template.php"); //In this file there's a code block 
    //{NOCACHE} 
     //Do something with $variable; 
    //{/NOCACHE} 


    } 

    public function cacheFile(){ 
    //If file exists cache file 
    //If found {NOCACHE} {/NOCACHE} execute the code needed to change the $variable between {NOCACHE}{/NOCACHE} 
    } 
} 

    ?> 

我想从do_string()方法得到确切的编码影响$变量的值。如何获取影响变量的所有php代码?

$someClass = new SomeClass() 
$some_string = $someClass->string //Retruns 4 
$some_string = $some_string + 2; 

$variable = $some_string; //6 

因此,以后我可以执行它,如果需要,我试图做一个缓存系统。 有没有像debug_backtrace(),但为$变量?

+2

在IDE中搜索$ var字符串? – Martin

+0

您希望直接引用和非直接引用? –

+1

@Martin即使不能保证,给定变量作用域和$ some_string可能会在代码中的其他地方用作完全不同的变量,或者您可以传递$ some_string作为函数参数,并且它被完全不同的引用名称 –

回答

0

在与你进一步谈论你想要达成的目标之后,我会正式回答你的问题,说这不能以你希望的方式以任何直截了当的方式完成。