Home > Backend Development > PHP Tutorial > 请教字符串拼接

请教字符串拼接

WBOY
Release: 2016-06-20 12:44:53
Original
740 people have browsed it

我想实现的是这个按钮按下去,如果cat_ID; ?>取到这个ID值,假设为6
则打开http://localhost/myweb/wp-admin/post-new.php?cat=6

我是这么写的:
onclick="window.location.href='./wp-admin/post-new.php?cat=cat_ID; ?>'" 

ID值也取到了,但是总是拼接不上,结果访问一直是:
http://localhost/myweb/wp-admin/post-new.php?cat=


请问这个地方到底怎么写才能实现这个HTML和PHP的混合拼接?


回复讨论(解决方案)

onclick="window.location.href='./wp-admin/post-new.php?cat=<?php $category[0]->cat_ID; ?>'"
Copy after login


改为:
onclick="window.location.href='./wp-admin/post-new.php?cat=<?php echo $category[0]->cat_ID; ?>'"
Copy after login

加个echo就可以了。

正解!送分给大侠!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template