PHP headers_sent() လုပ်ဆောင်ချက်
ဥပမာ
ခေါင်းစီးများမပို့ပါက၊ တစ်ခုပေးပို့ပါ-
<?php
if (!headers_sent()) {
header("Location: https://www.w3schools.com/");
exit;
}
?>
<html>
<body>
...
...
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
headers_sent() လုပ်ဆောင်ချက်သည် ခေါင်းစီးများကို ပေးပို့ခြင်း ရှိ/မရှိ စစ်ဆေးပေးသည်။
အထားအသို
headers_sent(file,line)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
file | Optional. If the file and line parameters are set, headers_sent() will put the PHP source file name and line number where output started in the file and line variables |
line | Optional. Specifies the line number where the output started |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | HTTP ခေါင်းစီးများကို ပို့လိုက်လျှင် အမှန်၊ မဟုတ်လျှင် FALSE |
---|---|
PHP ဗားရှင်း- | 4.0+ |
PHP Changelog- | PHP 4.3- ရွေးချယ်နိုင်သော ဖိုင် နှင့် လိုင်း ဘောင်များကို ထည့် ထားသည်။ |
နောက်ထပ် ဥပမာများ
ဥပမာ
ရွေးချယ်နိုင်သောဖိုင်နှင့် လိုင်းဘောင်များကို အသုံးပြုခြင်း-
<?php
// $file and $line are passed in for later use
// Do not assign them values beforehand
if (!headers_sent($file, $line))
{
header("Location: https://www.w3schools.com/");
exit;
// Trigger an error here
}
else
{
echo "Headers sent in $file on line $line";
exit;
}
?>
<html>
<body>
...
...
❮ PHP Network ရည်ညွှန်းချက်