Difference between executing php from the commandline and from the Http Side

后端 未结 7 1668
余生分开走
余生分开走 2020-12-09 18:32

What is the difference between executing php from command line and from HTTP? Do they use the same executable such as (php.exe or php-cgi.exe ( Apache or IIS ))? Do the r

相关标签:
7条回答
  • 2020-12-09 19:18

    Main difference is argument passing: running from the CLI, you don't have $_GET, $_POST, $_SESSION, etc; so arguments have to be passed as command line parameters and accessed using if $_SERVER['argc'] and $_SERVER['argv'] Watch out for the directory your code is running in and the include path; and make sure you know what php.ini you've loaded. When outputting, HTML markup doesn't render as markup, but displays as < h1> etc.... watch out particularly for
    (PHP_EOL is extremely useful) and multiple spaces or tabs actually appear as multiple spaces or tabs rathe rthan a single space. Forget headers() and other http-specific functions

    0 讨论(0)
提交回复
热议问题