Run PHP code inside JavaScript? Would this be ok to use?

前端 未结 4 1714
孤街浪徒
孤街浪徒 2021-01-21 03:43

I am not sure if a line of PHP could be run inside of a JavaScript function. For example:



        
4条回答
  •  孤街浪徒
    2021-01-21 04:14

    You need to print something with php. I don't understand what you are trying to do. You can use php inside javascript for templating but I suggest you use ajax.

    I would use jQuerys .ajax() function on the javascript side and echo json_encode($result_array) on the php side.

提交回复
热议问题