Is it possible to use variable in use statement? How to implement version control with traits and other files i define with use statement?
<?php
namespace SomeNamespace;
$vers = '10';
use SomeNamespace2\someTrait_$vers;
use SomeNamespace3\someTrait_$vers;
I would like to be able to assign single version to all use statements.
Although PHP has no support for variables in
use
statements, you could overcome that by putting youruse
statements (and other version specific code) into a series of include files (one for each version) and then use a variable in arequire
(orinclude
) statement to include the file you want. For example:use_10.php:
use_11.php:
Your main PHP code: