Overwriting a string by concatenating another string

There are hundreds of places in my project that contain the following code:

include $root . $template;

Where $rootis the document root for the corresponding part of CRM, and $templateis the HTML template file. The variable $rootis different for different parts of CRM.

Now I want all parts of CRM to use the same template file. I can't just change $rootto the root of the central document, because the code uses other places that use this variable. I just want to change it to load a template.

Is there a way to save time, so I don’t have to iterate over all the places in my code where this appears? Is it possible for a string to $templateoverwrite a string $rootwhen concatenating?

i.e.

$root="$_SERVER['document_root']."\some_folder";
$template="[something_to_ignore_concatination?]".$_SERVER['document_root']."\template_file";
//So $root.$template = just $template
+6
1

: , , , !

:

$_SERVER['document_root'] = 'path/to/root'

$root == $_SERVER['document_root'] . '/some_folder' == 'path/to/root/some_folder'

$template == '/' . $_SERVER['document_root'] . '/file.php' == '/path/to/root/file.php'

$root . $template == 'path/to/root/some_folder/path/to/root/file.php'

path/to/root/some_folder/path/to/root -> path/to/root/

.

. , PHP include_path.

+3

Source: https://habr.com/ru/post/1016473/


All Articles