dongshuo6185 2011-03-02 22:19
浏览 107
已采纳

将字符串变量从php传递给JS函数

I was looking for a way to pass a string(variable saved in a form of $x) from php to Java Script and I found so many codes to solve that, but my question is : does those strings have to be declared global?!
i did declare it as a global variable but still no response ..!
any other suggestions?!

Pass a PHP string to a JavaScript variable (and escape newlines)

I tried most of these codes, none of them worked,

  • 写回答

2条回答 默认 最新

  • dragon4587 2011-03-06 06:25
    关注

    As the others have said, all we can say is that you are doing something wrong. You can place PHP variable values, strings or otherwise, wherever you want in your JavaScript code, since PHP is server-side and can do whatever you like on the client side.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样