简体   繁体   English

php urlencode htmlentities问题

[英]php urlencode htmlentities issue

I'm getting an error: 我收到一个错误:

Warning: include(friday_set.php?x=First+Set&y=2): failed to open stream: No such file or directory in...

When I go to my url -> "friday_set.php?x=First+Set&y=2" everything comes out how it should 当我转到我的网址->“ friday_set.php?x = First + Set&y = 2”时,所有内容都会显示出来

I understand the main reason is that I'm not properly encoding the url and the url can't quantify the & 我了解主要原因是我没有正确编码网址,并且网址无法量化& in the string 在字符串中

My code is this (which is similar to what is described in the php manual ): 我的代码是这样的(类似于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));
?>

I can't seem to spot the problem...anyone have a solution?? 我似乎无法发现问题...任何人都有解决方案??

instead of parsing the vars in the file url i suggest this: 而不是解析文件url中的var,我建议这样做:

<?php
 $sel_name = 'First Set';
 $admin_id = '2';

   include ("friday_set.php");
?>

inside friday_set.php check for either $_GET[x] for direct url or $sel_name for include. 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM