Contributing Advent 8: The magic __FILE__ constant
This issue came up in the #xdebug IRC channel on Freenode:
18:25 <user> no magic constants for PHP ? 18:27 <user> __FILE__ evaluates to "xdebug://debug-eval"
The user noticed this issue in the Eclipse expression evaluator. A similar issue is also described a few times on the internet:
With the hint in comment 2 in the first URL, I answered the report in an answer on StackOverflow (the third URL). I am repeating this answer (with some modifications) here:
The output you get is not incorrect. __FILE__ is a special constant that gets evaluated at parser time. In fact, even though it looks like a constant, it is really not. When the PHP script gets compiled, it would really read something like this:
// test.php
<?php
"test.php";
?>
even though the script source was:
// test.php
<?php
__FILE__;
?>
This means that after parsing, there is no such "constant" __FILE__ at all, as it has already been replaced.
This means that if you evaluate __FILE__ in an IDE, through DBGp's eval command with eval -- __FILE__ it can not return you a filename that is represented through the __FILE__ "constant". Instead, it uses the filename for the current context which is xdebug eval or in later versions, xdebug://debug-eval.
In essence, it's the same as doing this:
php -r 'eval("__FILE__;");'
Which also outputs:
Command line code(1) : eval()'d code
Xdebug looks for this sort of output format, and changes it to xdebug://debug-eval so that it can actually debug into eval'ed code.
__FILE__ works as expected in "normal" PHP source code, as can be proven with this snippet:
<?php $currentFilename = __FILE__; ?>
And after it has been assigned to a variable, you can evaluate $currentFilename in your IDE.
Life Line
A Jack Snipe Seemingly Running Away
Jack Snipes aren't nearly as easy to see as the already well camouflaged Common Snipes. But this lovely bird showed up right on front of the hide at RSPB Rainham Marshes a few weekends ago, bobbing its tail while foraging.
#photography #Birds #BirdPhotography #BirdsOfFediverse #NaturePhotography #wildlife #RSPB #RainhamMarshes #london
@tubemapper Who/which company, do you use for making and/or printing your calendars? (And would you recommend them?)
These "Personal account for reading timelines." account requests are really getting annoying now. #FediAdmin
Finally A Photo Of A Cetti's Warbler
I have heard their songs countless times — they're very loud! And seen fleeting glances if then before. But finally one decided to almost pose on this branch in the reeds of the WWT London Wetland Centre, right in the city.
#photography #Birds #BirdPhotography #BirdsOfFediverse #NaturePhotography #wildlife #london #wwt
Merge branch 'v2022'
Fix test after recent data update
Specify motorcycle parking fees
Specify motorcycle parking capacities
Specify motorcycle parkings covers
Specify parking access
Specify whether public transport stops have bins
Specify whether pedestrian crossings have islands
Survey postbox collection times
Specify whether crosswalks have tactile paving
Specify whether kerbs have tactile paving
Determine the heights of kerbs
Specify bicycle parkings covers
Specify whether pedestrian crossings have markings
Specify whether pedestrian crossings have traffic signals
Specify whether there are crossings at intersections of paths and roads
Determine roads lane count
Specify whether roads have lane markings
Specify width of opening
Survey whether benches have backrests
Survey opening hours



Shortlink
This article has a short URL available: https://drck.me/adv1308-aex