I want to run sample.php from a command prompt in windows 10.
An error message appears when you run the file with php sample.php
as shown in the image.
Could not open input file:sample.php
php-v
If you run it with only the options, it will return as expected.
You can also launch Apache and get sample.php results for your web browser.
php windows-10 command-prompt
First, check the location of the sample.php. Is it stored under C:\php-7.4.13\
?
If you can see it from Apache, is it under C:\Apache24\htdocs\
for example?
Method 1
Once you have determined where to save it, open the command prompt and use the cd
command to navigate to the appropriate folder.(Let's say C:\Apache24\htdocs
)
C:\>cdc:\Apache24\htdocs
Once you have moved the folder, check the dir
command to see if the PHP file exists.
C:\Apache24\htdocs>dir
... A list of files that exist in the folder appears.
Once you have verified that you have a PHP file, try passing it to the arguments of the php
command.
C:\Apache24\htdocs>php sample.php
Method 2
You may want to know where to save the file and then specify the full path of the file as indicated in the comments.
C:\php-7.4.13>php C:\Apache24\htdocs\sample.php
© 2024 OneMinuteCode. All rights reserved.