CKTIS / PHP
Ključna beseda include
Izvede datoteko PHP v območju spremenljivk mesta vključitve. return v datoteki postane rezultat include.
Različica: PHP 8.4; repository runtime, production runtime not attested
Sintaksa
include $filenameIzvede datoteko PHP v območju spremenljivk mesta vključitve. return v datoteki postane rezultat include. Sicer uspešna vključitev običajno vrne 1. Manjkajoča datoteka povzroči opozorilo in false, izvajanje se lahko nadaljuje.
$file=tempnam(sys_get_temp_dir(),"inc"); file_put_contents($file,'<?php $x += 2; return $x * 3;');
function readLocal($file){$x=4; $total=include $file; return [$x,$total];}
echo json_encode(readLocal($file)); unlink($file);
[6,18]
Primeri
<?php
$file=tempnam(sys_get_temp_dir(),"inc"); file_put_contents($file,'<?php $x += 2; return $x * 3;');
function readLocal($file){$x=4; $total=include $file; return [$x,$total];}
echo json_encode(readLocal($file)); unlink($file);
Rezultat
[6,18]