Consider these two examples:
// explicitly setting the variable
$file = '/example.php';
if (file_exists($file)) {
include($file);
}
// setting the variable within a function call
if (file_exists($file = '/example.php')) {
include($file);
}
I tested both, and they seem to be working identical.
The second one seems much more concise and less prone to errors, despite having less characters. Yet, I've never seen this being used in practice, and guides will usually advertise the first method.
Are there any reasons against setting variables in this manner? If so, are they exclusively of coding style nature, or is there a technical difference? Are there any other differences I haven't addressed?