Portál AbcLinuxu, 6. května 2025 20:34
private function inc($a, $b){ return 'test'; }Potřebuji poradit, jak udělat return a include aby to fungovalo.
private function inc($a, $b){ return include '/my/dir/filename.php'; }Pomůže ,mě prosím někdo? Děkuji.
Řešení dotazu:
private function inc($a, $b){ return include '/my/dir/filename.php'; }A v souboru /my/dir/filename.php
return 'test'Má to na něco vliv? Zpomalení, více paměti atd.. ? Děkuji
private function inc($a, $b){
return file_get_contents ( '/my/dir/filename.php' );
}
fce.php
<?php
function fce($a, $b) {
...
return $something;
}
other.php
<?php
require 'fce.php';
fce('foo', 'bar');
a.php include("b.php"); echo "a"; b.php echo "b"; return;ale já echo nepoužívám v celém systému, až v konečné šabloně.
If called from the global scope, then execution of the current script file is ended. If the current script file was included or required, then control is passed back to the calling file. Furthermore, if the current script file was included, then the value given to return will be returned as the value of the include call.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.