how to inject code-block at line 1 in every .php insite of a projekt Follow
Answered
Hi there,
first of all, I am more new than well known as a programmer.
Ther is a phpstorm project, more or less a wordpress document-root.
I want to set something like this, into every .php file in the beginning, to see what happens, when calling my website.
<?php
if (RB_DEBUG){
echo __FILE__."<br>";
}
?>
Is there a way to do it easily?
Best regards
Ro
Please sign in to leave a comment.
It looks like you are trying to trace how the script actually gets executed (which files are used). I recommend using xdebug instead. https://xdebug.org/docs/profiler
Hi there,
Falnyr, thank you for your recommendation. Your are right, and xdebug might be the more powerfully way. So I do summarise: There is no way to inject code using phpstorm! Just asking again, because the possibility was not mentioned to be impossible.
Best regards
Ro
Roland, you can do that with Replace in Path having it set to the Regex mode and the file mask set to
*.php
.The search pattern would be
^\A(.*)$
, and the replacement pattern would be<?php print "inserted!";\?>\n$1
.You'll have to customize the replacement pattern of course, do not forget about escaping special chars!