Windows equivalent to #!/usr/bin/php

◇◆丶佛笑我妖孽 提交于 2019-12-01 12:34:18

问题


I am trying to execute a php file from sos-berlin jobscheduler. My OS is windows 7. I am following the documentation

http://www.sos-berlin.com/mediawiki/index.php/How_to_execute_a_PHP_script_with_JS

#!/usr/bin/php

<?php 

 echo "hello";

?>

But when I executed the script I am getting the error that

'#!' is not recognized as an internal or external command, operable program or batch file.

I came to understand that #!/usr/bin/php is a linux command. I should give here equivalent batch command. I googled, but didn't find any useful result. Please any one help me...

Thanks in advance.


回答1:


  1. Go to your desktop.
  2. Right click My Computer shortcut in the desktop.
  3. Click Properties.
  4. You should see a section of control Panel - Control Panel\System and Security\System.
  5. Click Advanced System Settings on the Left menu.
  6. Click Enviornment Variables towards the bottom of the window.
  7. Select PATH in the user variables list.
  8. Append your PHP Path (C:\myfolder\php) to your PATH variable, separated from the already existing string by a semi colon.
  9. Click OK
  10. Open your "cmd"
  11. Type PATH, press enter
  12. Make sure that you see your PHP folder among the list.

That should work.




回答2:


Suppose you have installed php.exe in C:\Program files\MyPhpProgram\php.exe

Then run below 2 lines on terminal (cmd.exe):

assoc .php=phpfile
ftype phpfile="C:\Program files\MyPhpProgram\php.exe" "%1"



回答3:


1) install a php engine on windows

2) in a cmd windows for example, run php

3) open cmd, go to where you installed php. and run c:\program files\php\php.exe .php

link to setting up the path to include php so you can run it easily from cmd:

http://willj.co/2012/10/run-wamp-php-windows-7-command-line/



来源:https://stackoverflow.com/questions/16646003/windows-equivalent-to-usr-bin-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!