����Linux�Ż�
Linux����

��Unix/Linux��ֱ��ִ��PHP�ű��ļ�

����ʱ��:2016-03-21 15:18:46��Դ:ijuer.com����:linux��

�������ǵķ���������ʹ�õ� Linux ϵͳ�����Ҷ��д������ PHP ������������ʱ���һ��� PHP дһЩִ���Զ�������Ľű�������ÿ��ִ����� PHP �ű�����Ҫʹ�� php myscript.php �ķ�ʽ����΢�е�����¡���ʵ���ǿ���ֱ��ִ�� PHP �ű��ļ��ġ�


��д��Ľű��ļ�

�������DZ�дһ������Ϊ test_run.php ���ļ����ļ����������£�

Here is some plain text.
Here is the file name:
<?php
echo $argv[0], PHP_EOL;
?>

�ű����ݺܼ򵥣����ǰѵ�ǰ�ű��ļ������ƴ�ӡ������

Ȼ������ʹ�� PHP ����ִ��һ������ű���

yuanyu@ymac:phpworkspace $ php test_run.php hello
Here is some plain text.
Here is the file name:
test_run.php
yuanyu@ymac:phpworkspace $


���ű��ļ�����ͷ��Ϣ����������Ȩ��

Ȼ��������ļ��ĵ�һ��д�� php �����ȫ·����ǰ����һ�� #!��

#!/usr/bin/php
Here is some plain text.
Here is the file name:
<?php
echo $argv[0], PHP_EOL;
?>

Ȼ�������ļ������ִ�е�Ȩ�ޣ�

yuanyu@ymac:phpworkspace $ chmod u+x ./test_run.php

�������Ϳ���ֱ��ִ������ű��ˣ�

yuanyu@ymac:phpworkspace $ ./test_run.php
Here is some plain text.
Here is the file name:
./test_run.php
yuanyu@ymac:phpworkspace $


���ַ�ʽ�� PHP �ٷ��ĵ���Ҳ����˵�ģ���ο���

http://php.net/manual/en/features.commandline.usage.php

�ĵ��е�

“Example #2 Script intended to be run from command line (script.php)”


�������ø��µ�ַ��//m.ajphoenix.com/linux/19129.html