I can’t run PHP code in VS Code

Asked

Viewed 174 times

0

I have been trying to run PHP code on the VS Code terminal. Whenever I try to do so this message appears:

*c:~\Users\Thiago\Downloads\Training.php
\SP.php : O termo 'c:~\Users\Thiago\Dow 
nloads\Training.php\SP.php'* não é       
reconhecido como nome de cmdlet,        
função, arquivo de script ou programa   
operável. Verifique a grafia do nome    
ou, se um caminho tiver sido incluído,  
veja se o caminho está correto e tente  
novamente. não é       
reconhecido como nome de cmdlet,        
função, arquivo de script ou programa   
operável. Verifique a grafia do nome    
ou, se um caminho tiver sido incluído,  
veja se o caminho está correto e tente  
novamente.

What am I doing wrong?

  • How are you trying to run the code? You really want to run a script or "create a website"?

1 answer

1


The PHP programming language was made to work on the server, to run the PHP scripts you will have to open a server, to open just use XAMPP and start apache on the home screen of XAMPP, so that PHP scripts can be executed you will need to save the files in the folder C:/xampp/htdocs. There is also another way to open a server, starting from version 7 of PHP comes embedded web server, to run simply go in the directory that was saved the files in PHP and run this command php -S localhost:8080, to run the scripts you will need to open the browser and access the localhost.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.