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.只要有可能。


Leave a Reply留下回复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用這些標記:<a title="">的title=""> <acronym title="">的首字母的<b> <blockquote cite=""> <cite>的<code>“刪除日期=“”“<em>的<i> <q cite=""> <strike>的<strong>

Subscribe to comments feature has been disabled. 訂閱評論功能已被禁用。 To receive notification of latest comments posted, subscribe to 收到通知最新的評論張貼,贊同 My Digital Life Comments RSS feed 我的數字生活評論RSS飼料 or register to receive 註冊以接收 new comments in daily email digest. 在新的評論的電子郵件每天消化。
Custom Search

New Articles新文章

Incoming Search Terms for the Article接踵而來的查尋期限為文章

error fix 錯誤修復 - - "Call to undefined function read_global" “召喚未定義函數read_global” - - Call to undefined function read_global() 調用未定義函數read_global() - - "AD" "Call to undefined function" “公元”,“召喚未定義函數” - - undefined function read_global adsense mobile 未定義的函數read_global的AdSense移動 - - HTTP_USER_AGENT xperia HTTP_USER_AGENT xperia - - read_global read_global - -