Is it possible to include assembly code in a PHP script?

I mean something like this:

asm( //assembly code here mov dx, 4 // etc... ) 

asm () - php function

perhaps?

+3
source share
2 answers

No, It is Immpossible. Closest you can use exec() or similar functions to call external programs or scripts.

+8
source

In short, no.

PHP scripts are compiled into bytecode specific to a particular virtual machine (assuming Zend Engine here). Thus, you cannot mix native and PHP code with a standard distribution.

However, it is possible to write C extensions for PHP in which you can use the built-in assembly.

+1
source

Source: https://habr.com/ru/post/956466/


All Articles