Fix Call to Undefined Function read_global() Error in Google AdSense Mobile Content PHP Ad Code修正召喚未定義函數read_global()錯誤在谷歌的AdSense移動廣告代碼PHP的內容
Google AdSense allows mobile websites to monetize traffic by placing Google AdSense for Mobile Content targeted ads.谷歌的AdSense允許移動網站賺錢交通放置谷歌AdSense移動廣告的廣告。 However, when placing the PHP-based Google AdSense ad code for “All Phones” device type into PHP web pages of mobile sites, the following error message may appear, and log on Apache error log.然而,當放置基於PHP的谷歌的AdSense廣告代碼為“所有手機”的設備類型到PHP網頁的移動網站,下面的錯誤信息可能會出現,並登錄Apache的錯誤日誌。
PHP Fatal error: Call to undefined function read_global() in wap/index.php on line 88 PHP的致命錯誤:調用未定義的函數read_global()在WAP /編輯在線88
In PHP Google AdSense for Mobile Content code, there are several global variable declarations which require read_global function.在PHP谷歌AdSense移動廣告代碼,有幾個全局變量聲明,需要read_global功能。 The problem is that the read_global() function is only declared later in the AdSense code, and not before the lines of code which require the function.但問題是,read_global()函數僅在稍後宣布AdSense代碼,而不是前行代碼需要的功能。 In some PHP implementation, a function has to be explicitly declared and loaded before the function is called.在一些PHP的執行,函數必須明確宣布之前加載和調用函數。
To solve the PHP call to undefined function read_global() fatal error of Google AdSense for Mobile Content code, try to move the function declaration of read_global() to the top of the ad code block, ie above all the $GLOBALS['google'] lines.為了解決了PHP調用未定義的函數read_global()致命錯誤的谷歌AdSense移動廣告代碼,嘗試移動函數聲明的read_global()最上方的廣告代碼塊,即首先是$全局['谷歌' ]行。 The function is declared in the following block of code:函數聲明如下代碼塊:
function read_global($var) {
return isset($_SERVER[$var]) ? $_SERVER[$var]: '';
}
The PHP error should be solved by moving the function declaration to the top. PHP的錯誤應該被解決移動函數聲明頂端。 However, websites which having this error may continue to face other undefined function errors for google_set_screen_res(), google_set_muid() and google_set_via_and_accept().然而,該網站有此錯誤可能會繼續面臨其他不確定的函數錯誤的google_set_screen_res(),google_set_muid()和google_set_via_and_accept()。
Likewise, just move the function declaration blocks to above the line where respective function is called, or simply move the line of code where function is called to below the function declaration block, will solve most errors.同樣,只要將函數聲明塊以上的行,其中各自的函數被調用,或只要將其中的代碼行函數調用以下函數聲明塊,能解決大部分錯誤。
For example,例如,
function google_set_screen_res() {
$screen_res = read_global('HTTP_UA_PIXELS');
if ($screen_res == '') {
$screen_res = read_global('HTTP_X_UP_DEVCAP_SCREENPIXELS');
}
if ($screen_res == '') {
$screen_res = read_global('HTTP_X_JPHONE_DISPLAY');
}
$res_array = split('[x,*]', $screen_res);
if (sizeof($res_array) == 2) {
$GLOBALS['google']['u_w'] = $res_array[0];
$GLOBALS['google']['u_h'] = $res_array[1];
}
}
google_set_screen_res();
function google_set_muid() {
$muid = read_global('HTTP_X_DCMGUID');
if ($muid != '') {
$GLOBALS['google']['muid'] = $muid;
}
$muid = read_global('HTTP_X_UP_SUBNO');
if ($muid != '') {
$GLOBALS['google']['muid'] = $muid;
}
$muid = read_global('HTTP_X_JPHONE_UID');
if ($muid != '') {
$GLOBALS['google']['muid'] = $muid;
}
$muid = read_global('HTTP_X_EM_UID');
if ($muid != '') {
$GLOBALS['google']['muid'] = $muid;
}
}
google_set_muid();
function google_set_via_and_accept() {
$ua = read_global('HTTP_USER_AGENT');
if ($ua == '') {
$GLOBALS['google']['via'] = read_global('HTTP_VIA');
$GLOBALS['google']['accept'] = read_global('HTTP_ACCEPT');
}
}
google_set_via_and_accept();
IMPORTANT : The page is machine translated and provided "as is" without warranty. 重要說明 :該網頁是機器翻譯,並提供“按原樣”不做。 Machine translation may be difficult to understand.機器翻譯可能很難理解。 Please refer to請參閱 original English article英文原版的文章 whenever possible.只要有可能。
Related Articles相關文章
- WordPress Call To Undefined Function get_currentuserinfo() PHP Error WordPress的呼叫未定義功能get_currentuserinfo()PHP的錯誤
- Fix Fatal Error Call to Function get_link() on Non-Object in WordPress 2.8 Dashboard with Technorati Incoming Links RSS修正致命錯誤召喚功能get_link()非對象在WordPress 2.8儀表板與Technorati接踵而來的鏈接的RSS
- Add and Put AdSense Ads Code and JavaScript to Google Page Creator Website添加和放置AdSense廣告代碼和JavaScript來谷歌網頁製作網站
- Google Adsense New Ads Revenue Stream – Content Referral Network谷歌Adsense新廣告的收入來源-內容推介網絡
- google_ad_host Host ID in Google AdSense Ad Unit Code and Revenue Sharing google_ad_host主機ID在谷歌的AdSense廣告單元代碼和收入分享
- The Call to DllRegisterServer Failed with Error Code 0×80004005 on Windows Vista呼籲的DllRegisterServer失敗,錯誤代碼0 × 80004005在Windows Vista
- Google AdSense Legacy Old Generation Code Reference (Generate and Get)谷歌的AdSense傳統老一代代碼參考(生成和獲取)
- Implement Ad Revenue Sharing in Blogger (Supports Google AdSense And Any Code)實現廣告收入共享的Blogger(谷歌AdSense和支持任何代碼)
- How to Wrap AdSense Ads Around and Inline Beside Blogger Post Content如何總結AdSense廣告約和內聯除了Blogger帖子內容
- Monitor Google AdSense Account With Shock AdSense監視器谷歌的AdSense帳戶與休克的AdSense









































