[英]php urlencode htmlentities issue
我收到一個錯誤:
Warning: include(friday_set.php?x=First+Set&y=2): failed to open stream: No such file or directory in...
當我轉到我的網址->“ friday_set.php?x = First + Set&y = 2”時,所有內容都會顯示出來
我了解主要原因是我沒有正確編碼網址,並且網址無法量化&
在字符串中
我的代碼是這樣的(類似於php手冊中的描述):
<?php
$sel_name = 'First Set';
$admin_id = '2';
$query_string = 'x=' . urlencode($sel_name) . "&y=" . urlencode($admin_id);
include ("friday_set.php?" . htmlentities($query_string));
?>
我似乎無法發現問題...任何人都有解決方案??
而不是解析文件url中的var,我建議這樣做:
<?php
$sel_name = 'First Set';
$admin_id = '2';
include ("friday_set.php");
?>
在friday_set.php
檢查$_GET[x]
作為直接URL或$sel_name
作為include。
if(isset($_GET['x'])){
$sel_name=$_GET['x'];
}//else $sel_name is just $sel_name unless you want to check its populated also
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.