douhan9619 2013-09-29 08:04
浏览 8

如何在PHP中调用字符串中的变量值

How do I call my PHP initialized variable inside the string of onclick="" ? I have Initialized $counter=7 and want to use that counter inside onclick="" function. This is how I did which is not working.

<a class="blogpost page-transition" href="the_permalink();" onclick="gotoPageWithTrans6($counter)">

I also Tried doing this, but the following code also didn't worked.

<a class="blogpost page-transition" href="the_permalink();" onclick="gotoPageWithTrans6(?php $counter ?> )">

Any solution ?

  • 写回答

4条回答 默认 最新

  • douzao1119 2013-09-29 08:05
    关注

    You are only missing the echo statement:

    a class="blogpost page-transition" href="<?php echo the_permalink(); ?>" onclick="gotoPageWithTrans6(<?php echo $counter ?> )
    
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?