2013-05-22 27 views
2

我有在本網站的快捷方式鏈接了一個問題:http://smileshort.com/short-anonymous-links-api.html警告:未知:您的腳本可能依賴於它一直存在到PHP會話副作用4.2.3

使用的API:http://smileshort.com/api.php?key=534287562&url=google.com

讓我看看這個問題

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0 

當我使用這個功能

<?php 

function get_vgd($url) 
{ 
$apiurl = "http://smileshort.com/api.php?key=890479270&url=$url"; 
$ch = curl_init(); 
$timeout = 3; 
curl_setopt($ch,CURLOPT_URL,$apiurl); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); 
$data = curl_exec($ch); 
curl_close($ch); 
return $data; 
} 
echo get_vgd("http://www.google.com"); 

?> 

回答

2

有一個與一些現有的全局變量同名的會話變量。存在$_SESSION['name']$name)。
重命名其中任何一個。

它應該是一個相當重複的問題,因爲它發生在我身上。

+0

我不明白我在哪裏必須編輯我的代碼。如果你的意思是這個鏈接中的一個會話:http://smileshort.com/short-anonymous-links-api.html ...但我無法控制這個網站,非常感謝! – omardealo

1

可能還有其他原因導致此錯誤。如果有人來到這個線程,並知道沒有重複的變量。

如果你這樣做

unset($var); 
$_SESSION['sessVar'] = $var; 

因爲你設置一個未定義的變量,會話變量,你會得到同樣的警告。未設定通常是不存在的,那只是爲了說明:)

0

我只是有這個問題,併爲問題的原因是

沒有定義了一個名爲頁面上的變量。

它讓我偏離軌道,讓我非常擔心,但現在我已經定義了$ Var它不再打印Warning。