-
-
Save turtlix/60900be21d20a36c20f23c861e705f41 to your computer and use it in GitHub Desktop.
Revisions
-
kylefarris revised this gist
Mar 18, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ function get_calling_class() { $trace = debug_backtrace(); // Get the class that is asking for who awoke it $class = ( isset( $trace[1]['class'] ) ? $trace[1]['class'] : NULL ); // +1 to i cos we have to account for calling this function for ( $i=1; $i<count( $trace ); $i++ ) { -
kylefarris revised this gist
Mar 18, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ function get_calling_class() { // +1 to i cos we have to account for calling this function for ( $i=1; $i<count( $trace ); $i++ ) { if ( isset( $trace[$i] ) && isset( $trace[$i]['class'] ) ) // is it set? if ( $class != $trace[$i]['class'] ) // is it a different class return $trace[$i]['class']; } -
kylefarris revised this gist
Mar 18, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ function get_calling_class() { // +1 to i cos we have to account for calling this function for ( $i=1; $i<count( $trace ); $i++ ) { if ( isset( $trace[$i] ) && isset( $traece[$i] ) ) // is it set? if ( $class != $trace[$i]['class'] ) // is it a different class return $trace[$i]['class']; } -
hamstar revised this gist
Aug 3, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ /*********************************************************** ******* SIMPLE TEST **/ class A { function t() { @@ -15,4 +15,4 @@ function x() { } $b = new B; $b->x(); // prints B -
hamstar revised this gist
Aug 3, 2011 . 2 changed files with 19 additions and 31 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ /*********************************************************** ******* SIMPLE TEST */ class A { function t() { echo get_calling_class(); } } class B { function x() { $a = new A; $a->t(); } } $b = new B; $b->x(); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,34 +14,4 @@ function get_calling_class() { if ( $class != $trace[$i]['class'] ) // is it a different class return $trace[$i]['class']; } } -
hamstar revised this gist
Aug 3, 2011 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,13 +2,16 @@ function get_calling_class() { //get the trace $trace = debug_backtrace(); // Get the class that is asking for who awoke it $class = $trace[1]['class']; // +1 to i cos we have to account for calling this function for ( $i=1; $i<count( $trace ); $i++ ) { if ( isset( $trace[$i] ) ) // is it set? if ( $class != $trace[$i]['class'] ) // is it a different class return $trace[$i]['class']; } } -
hamstar created this gist
Aug 3, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ <?php function get_calling_class() { $trace=debug_backtrace(); $class = $trace[1]['class']; // +1 for ( $i=1; $i<count( $trace ); $i++ ) { if ( isset( $trace[$i] ) ) if ( $class != $trace[$i]['class'] ) return $trace[$i]['class']; } } /*********************************************************** ******* SIMPLE TEST php> class A { ... function t() { ... echo get_calling_class(); ... } ... } php> class B { ... function x() { ... $a = new A; ... $a->t(); ... } ... } php> $b = newB; // LOL WHOOPS! phpsh assumes I'm inexperienced now... PHP Notice: Use of undefined constant newB - assumed 'newB' in /usr/local/lib/python2.7/dist-packages/phpsh/phpsh.php(578) : eval()'d code on line 1 Notice: Use of undefined constant newB - assumed 'newB' in /usr/local/lib/python2.7/dist-packages/phpsh/phpsh.php(578) : eval()'d code on line 1 php> $b = new B; php> $b->x(); B //Yay it works! ********************************/