Home > Backend Development > PHP Problem > Why doesn't php need to be compiled?

Why doesn't php need to be compiled?

(*-*)浩
Release: 2023-02-25 06:06:02
Original
4117 people have browsed it

Why doesn't php need to be compiled?

Although PHP does not need to be compiled, can it really be run after being written?

One of the major features of PHP is the scripting language. A script is usually interpreted and run instead of compiled.

PHP is an interpreted language. The PHP code is interpreted into opcode and then handed over to the Zend engine for execution. (Recommended learning: PHP programming from entry to proficiency)

Interpreted language: the program does not need to be compiled, the program is translated into machine language when it is run, and every time it is executed Translate every time.

Interpreted language

The source program is precompiled into an intermediate language before the program is run, and then the intermediate language is executed by the interpreter each time the interpreted language is executed Language programs need to be compiled once, so the running efficiency of interpreted language programs is usually low, and it cannot run independently from the interpreter. C#, PHP, Python, Java, etc. are all interpreted languages.

But can it really be run after writing? But no.

If PHP code wants to run, it must have a "mother" - the "PHP executable program" we compiled.

In Linux, this matrix may be placed in /usr/local/php/bin/php

How to run it?

1./usr/local/php/bin/php followed by a PHP file

2./usr/local/php/bin/php -r 'here Directly write the PHP code '

3. Create a file and write #!/usr/local/php/bin/php

on the first line so that you can identify whether the file is PHP to run (the file name does not have to end with .php)

Example:

$ vi god
Copy after login
#/usr/local/php/bin/php<?php
    echo &#39;hello world!&#39;.PHP_EOL;
Copy after login

The above is the detailed content of Why doesn't php need to be compiled?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template