How can I call PHP functions by JavaScript?

后端 未结 11 1185
情话喂你
情话喂你 2020-11-22 12:08

I am trying to call a PHP function from an external PHP file into a JavaScript script. My code is different and large, so I am writing a sample code here.

This is m

11条回答
  •  孤街浪徒
    2020-11-22 12:37

    I created this library JS PHP Import which you can download from github, and use whenever and wherever you want.

    The library allows importing php functions and class methods into javascript browser environment thus they can be accessed as javascript functions and methods by using their actual names. The code uses javascript promises so you can chain functions returns.

    I hope it may useful to you.

    Example:

    
    

提交回复
热议问题