简体   繁体   中英

I cannot locate the declaration of a site-wide variable

I am not an experienced .php programmer but know enough to understand the code. A 3rd party company built a site for me where they are using a variable called domain and echoing that in the URL paths.

<?php echo domain;?>css/style.css

The variable is not declared on the page with $domain I cannot find where this variable is declared anywhere in the .php pages. Where else should I be looking for this?

If this "variable" have not a $ before name, it is a constant.

Constants are defined in PHP using

define("constant_name", "constant_value");

Then you should find in your files for

define("domain" or just for define(

And find the line that set the domain.

1) grepping the variable name via terminal or any other cli throughout your project

2) search in all the includes in that file

3) search through all config and extended files

You could try something like this:

<?
  ini_set('display_errors', '1');
  define("domain","somethingsomethingblabla");
?>

You add this to one of the files where echo domain; exists, but before any includes , at the very top of the file.

So when you open that file, it will define the domain constant, and when that same constant is defined in one of the included files, php will throw notice saying:

PHP Notice: Constant domain already defined in /path/to/file.php on line XX

And voila, there you go, there is a call to define domain constant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM