// code ... echo $sTitle; // Как тут вывести 'Привет!', который инициализируется позже вывода? // code ... $sTitle = 'Привет!'; Is it possible?
You can enable buffering, place anchors, and then in their place insert the necessary values
http://php.net/manual/ru/function.ob-start.php
<?php ob_start(); echo '$sTitle'; $sTitle = 'Привет!'; $out=ob_get_clean(); echo str_replace('$sTitle',$sTitle,$out); In principle, the code above can be made to work as you want (although I don’t imagine why this may be necessary and it’s better not to do so ):
$assigned = false; myLabel: echo $sTitle; $sTitle = 'Привет!'; if (!$assigned) { $assigned = true; goto myLabel; } In this case, obviously, we still see the warning Undefined variable: sTitle (with the appropriate level of error_reporting ).
You can still dodge through self-include:
if (!isset($included)) { $included = true; include __FILE__; } echo $sTitle; $sTitle = 'Привет!'; Source: https://ru.stackoverflow.com/questions/588993/
All Articles
// code ...It may well be that everything is possible - KoVadim// code...? - j-tapfunction Hi($sTitle) { echo $sTitle; } $sTitle = 'Привет!'; Hi($sTitle);function Hi($sTitle) { echo $sTitle; } $sTitle = 'Привет!'; Hi($sTitle);- KoVadim