![](/img/trans.png)
[英]Why does Ajax give me a cross origin error when I can make the request from PHP?
[英]Why does it give an error when I add googlesnippets ld + json to my php page? 503 Service Unavaible
編輯:我們從詳細的研究中發現,由於腳本錯誤而導致即時密度下降時,cpu過期應降為503。 感謝您的所有答復。
我的電子商務php索引頁面腳本添加了Google片段ld + json java腳本在一段時間后出現錯誤(503服務不可用)。
我在cPanel上保存了php display_errors滴答,我再次保存了。 工作正常。 然后,過了一會兒,它突然出現503錯誤。從頁面中刪除javascript代碼后,當我清除緩存時,它不再給出任何錯誤。
在我的功能文件中創建:
function GoogleSnippetsWebsite($snippets) {
$out ='<script type="application/ld+json">{'."\n";
$out.='"@context":"https://schema.org",'."\n";
$out.='"@type": "WebSite",'."\n";
$out.='"url": "https://www.-----.com",'."\n";
$out.='"name":"----.com",'."\n";
$out.=' "inLanguage":"en-US",'."\n";
$out.=' "sameAs":['."\n";
$out.=' "https://www.---.com/",'."\n";
$out.=' "https://www.---.com/" ],'."\n";
$out.=' "potentialAction": {'."\n";
$out.='"@type": "SearchAction",'."\n";
$out.='"target": "https://www.----.com/search=&src={search_term_string}",'."\n";
$out.='"query-input": "required name=search_term_string"}}'."\n";
$out.='</script>'."\n";
return $out;
}
我想顯示我的php頁面:
<head>
<?php echo GoogleSnippetsWebsite('website'); ?>
</head>
工作5分鍾。 503服務不可用后。
也許很簡單,但我無法解決。 我沒有在Google搜索中得到結果。 您有什么建議? 謝謝。
503服務不可用
您首先使用$deger
然后使用$deger
$out
,所以$out
字符串沒有第一行。
請注意,因為您沒有首先啟動$out
,它一定是503錯誤的來源。
為了獲得更好的可讀性,我建議避免在每行上使用$out.=
,只需在開頭使用一個點進行連接,並在末尾刪除每個分號(最后一個連接除外)。
function GoogleSnippetsWebsite($snippets) {
$out ='<script type="application/ld+json">{'."\n"
.'"@context":"https://schema.org",'."\n"
.'"@type": "WebSite",'."\n";
.'"url": "https://www.-----.com",'."\n"
.'"name":"----.com",'."\n"
.' "inLanguage":"en-US",'."\n"
.' "sameAs":['."\n"
.' "https://www.---.com/",'."\n"
.' "https://www.---.com/" ],'."\n"
.' "potentialAction": {'."\n"
.'"@type": "SearchAction",'."\n"
.'"target": "https://www.----.com/search=&src={search_term_string}",'."\n"
.'"query-input": "required name=search_term_string"}}'."\n"
.'</script>'."\n";
return $out;
}
我會說我個人使用PHP_EOL
而不是"\\n"
;)
如果服務器資源不足以執行請求要執行的操作,則HTTP 503(服務不可用)通常是錯誤。 看您的問題,情況似乎也是如此,因為它在服務器返回此錯誤消息之前可以工作幾分鍾。
確保您有足夠的帶寬和存儲空間可使用。 一種解決方案是在沒有這些限制的情況下獲得主機
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.