ฟังก์ชั่น getenv()
ความหมายของฟังก์ชั่นและการใช้งาน
การคืนค่าข้อมูลของตัวแปร SERVER หรือ ENV โดยจะคืนค่า false ถ้าหากเกิดความผิดพลาด ด้วยฟังก์ชั่น getenv()
รูปแบบการเขียน (Syntax)
string getenv ( string $varname [, bool $local_only = false ] )
ตัวอย่างที่ 1
<?php
// Example use of getenv()
$ip = getenv('REMOTE_ADDR');
// Or simply use a Superglobal ($_SERVER or $_ENV)
$ip = $_SERVER['REMOTE_ADDR'];
// Safely get the value of an environment variable, ignoring whether
// or not it was set by a SAPI or has been changed with putenv
$ip = getenv('REMOTE_ADDR', true) ?: getenv('REMOTE_ADDR')
?>