简体   繁体   中英

Can I use PHP scripts in Firefox extension?

如果将PHP脚本放在“数据”目录中,可以在Firefox附加组件中使用它吗?

Firefox add-ons can only execute JavaScript. This still leaves you with a few options:

  • Rewrite the PHP code in javascript by hand
  • Rewrite the PHP code in javascript by hand, using a library like phpjs which emulate PHPfunctions in javascript
  • Use a PHP-to-JavaScript transpiler to convert the code (might only work for simple code)
  • use a PHP interpreter that is written in JavaScript, like this one and execute the PHP script

(I just googled those links and have no idea how well they work, there probably are better alternatives)

A rewrite of the PHP code is the only clean way in my opinion. Carefully migrating the most basic code with a transpiler might save some time though.

Firefox不能直接在扩展名中使用php,除非您通过XPCOM或其他解决方法间接调用php代码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM