duanfang2708 2009-12-01 22:50
浏览 80
已采纳

PHP的main.c如何开始执行

I was poking around the PHP 5.3.1 source tree, and decided to take a look at main.c. I was curious what was happening behind the scenes whenever PHP runs.

I was under the impression that any C or C++ program starts execution in a function named main, but I don't see a function with that name in main.c.

Where does PHP code actually start executing (a different for command-line vs. MOD_PHP vs. CGI?), and what am I missing w/r/t no main function in the main.c file that would let me answer this question myself the next time?

  • 写回答

3条回答 默认 最新

  • dongquan8753 2009-12-01 22:59
    关注

    I don't think I've ever seen any clear answer to that kind of question on the Internet, but you might be interested by some paragraphs of the book Extending and Embedding PHP, which is probably the reference book when it comes to writting PHP extensions, and the internals of the PHP engine.

    An interesting couple of sentences, quoting chapter 1 "The PHP Life Cycle", is :

    In a common webserver environment, you'll never explicitly start the PHP interpreter ; you'll start Apache or some other web server that will load PHP and process scripts as needed...

    And, just after :

    ... the CLI binary actually behaves just the same way. A php command, entered at the system prompt, starts up the "command line API", which acts as a mini-web server designed to service a single request.

    You'll probably be able to find some pages on Google books, if you want to try reading a bit more...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 Ubuntu20.04无法连接GitHub
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥30 C++行情软件的tick数据如何高效的合成K线