Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中,将字符串追加到变量URL的末尾_Php_Url_Append - Fatal编程技术网

在PHP中,将字符串追加到变量URL的末尾

在PHP中,将字符串追加到变量URL的末尾,php,url,append,Php,Url,Append,我在wordpress小部件中有一个youtube链接的代码 $title = "<h5 class='widget_title sidebar_widget_title'><a href='http://www.youtube.com/user/".$options['username']."' target='_blank'>".$options['title']."</a></h5>"; $title=”“; 所以我试图附加 ?子

我在wordpress小部件中有一个youtube链接的代码

 $title  = "<h5 class='widget_title sidebar_widget_title'><a
 href='http://www.youtube.com/user/".$options['username']."'
 target='_blank'>".$options['title']."</a></h5>";
$title=”“;
所以我试图附加

?子确认=1


在我的youtube用户名之后,会出现订阅确认,但是哇,我已经尝试了所有方法,只是还不是一个足够好的编码员。

您只需在字符串中插入查询字符串参数

$title  = "<h5 class='widget_title sidebar_widget_title'><a href='http://www.youtube.com/user/".$options['username']."?sub_confirmation=1' target='_blank'>".$options['title']."</a></h5>";
$title=”“;
这可能让您感到困惑的原因是,您正在更改的代码的作者使用了
告诉PHP下一个字符序列形成了一个字符串,
告诉HTML这是href属性的值(如
)。这是有效的,因为HTML同时支持
,这样就省去了转义引号的麻烦


就我个人而言,我宁愿对PHP字符串使用
,对HTML使用常规的
,但这是一个品味问题。

它的工作方式与您已经连接字符串的方式相同。显示您尝试过的内容,然后您会得到更好的反馈,因为它更清楚您遇到的障碍。