我的目標是使用PHP將這個浮動值分配給一個變數。 $weight = float value...
這是我做的代碼,希望它能起作用:
這是我做的代碼。
$url = 'http://example.com/weight'。
$url_components = parse_url($url)。
parse_str($url_components['weight'], $params)。)
$weight = $params['weight']。
echo $weight;
但這沒有回傳任何東西......
我在做什么?
我做錯了什么?
我做錯了什么?
uj5u.com熱心網友回復:
如果你想檢索一個url的內容,你可以使用file_get_contents()函式。實作起來會是這樣的:
$url = 'http://example.com/weight'。
$weight = file_get_contents($url)。
echo $weight;
另外,你可能想使用一個類似floatval()的函式來將你的結果轉換為浮點數。
在這里閱讀更多關于file_get_contents()的內容。https://www.w3schools.com/php/func_filesystem_file_get_contents.asp
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/319538.html
標籤:
上一篇:FastAPI動態多路徑引數

