This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 5 years ago.
Simple, I had a html that echo from php (saven in .php) but not even a simpe code as
<?php echo"ggg"; ?>
works, I tried with xammp and Wamp either chrome and firefox but doesn't work.
What can I do?
edit: already solved, I forgot to run it from localhost, thank you all.
Any of these (or more) could be your answer why it is not working
Is there actually PHP running on your computer? Check it with <?php echo phpinfo(); ?>
Are you accesing the file through your browser doing something like http://localhost/myfile.php
If it is on a remote server, is there PHP installed?
https://stackoverflow.com/a/43129028/2151290
Put your file inside c:/xampp/htdocs for xampp or c:/wamp/www for wamp
// Note that drive name may vary depending where you install c: or d:
Related
This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 3 years ago.
I just started to learn php. I am using lubuntu and that's why I don't want to install xampp, wamp, or similar programs because I have very limited resources.
I installed Apache server and php 7, which seems to be working fine because I can execute and visualize html code via localhost. The problem is when I run php code the web page shows blank. How can I fix this issue?
I have only one file on /var/www/html which is called index.php and can be visualize on localhost/index.php
php -v
php 7.2.19-0ubuntu0.18.10.1
apache2 -v
Server version: Apache/2.4.34 (Ubuntu)
The code I have on index.php is this:
<!DOCTYPE html>
<html>
<body>
something
<?php
echo "hello world";
?>
</body>
</html>
On localhost/index.php it only shows "something", which means apache server is running correctly and runs html code but I don't know why php doesn't run. If Instead I just run a file with php code like
<? php
phpinfo();
?>
it only shows a blank page.
If you see a blank page then normally something else is blowing up behind the scene. I suggest you check both Apache and PHP error logs. Normally you would find both in /var/log/*
It could very well be permission related or a module missing.
This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 5 years ago.
when i type my php code in a html file, using notepad++ as my text editor,why does it always show some of the code as text on the web page
eg.
<?php echo "hello world"; ?>
would output:
"hello world";?>
as text on the web page
why does it do this and how can I stop it?
You need to save your PHP code in a file with .php extension. To execute PHP code, you can call the interpreter from your command line with php myfile.php or from a webserver like Apache or nginx.
Your browser cannot execute PHP code.
Read more about installing PHP here:
http://php.net/manual/en/install.php
If you're new to PHP, I would recommend you to read a good book (unfortunately I can't recommend one). Or if you're more the visual learner, take a look at The PHP Practioner made by Jeffrey Way.
This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 5 years ago.
So I'm just starting to learn php, and when trying " Hello World" the file isn't executing properly. I have Bitnami MAMP Stack 5.6.31 .
I'm pretty sure it's not something wrong with the code, possibly with the install of the AMP stack, but this is the code anyway :
<?php echo "Hello World"; ?>
You can't just "open" PHP files on XAMPP/MAMP/LAMPP/etc.
Make sure your apache service is started in your MAMP console
Make sure your file is saved in the document root of MAMP, which by default is 'MAMP/htdocs'
If your file, say is stored like this: 'MAMP/htdocs/learningPHP/hello.php' then you would go to your web browser and type in localhost/learningPHP/hello.php
The script will then run.
This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 5 years ago.
I am trying to create a php loop as follows:
<?php
for ($i= 0; $i < 18; $i++)
{
echo "hello World";
echo "</br>";
}
?>
when I run it I get this as an output:
"; } ?>
However when I used http://www.writephponline.com/ I get the expected output.
I'm using notepad++ and chrome. The file has a .php ext.
Is there something missing?
Surely it is a silly mistake but can't figure it out. I appreciate your help.
You need to be running a web server with php installed. You appear to be loading the file directly from a server with no php installed, or as a file directly, without a server.
Your file is being interpreted as HTML not PHP
you are missing the php interpreter....
As you are using windows, you can take a look to WAMP to setup a working php enviroment http://www.wampserver.com/en/
browser can't run your php code.
here is a way that you could run your php code :
1. open terminal
2. go to the directory where your file exist
3. type this command "php -S localhost:8000"
now open your browser and goto http://localhost:8000/YOUR_FILE_NAME.php" or just http://localhost:8000/ if the file name is index.php
NOTE : you should have php installed in your computer
This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 5 years ago.
in the following 2 images i just want to run a very simple php code (file:///C:/wamp/www/test/1.php)
using a running WampServer Version 3.0.6 64bit then the result when i try to execute this file in browser still the same code as i written
php code
my browser
Note that you are opening a file.In URL its opening file://... but when you want the localhost server to process the file, you need to open your file as http://localhost/test/1.php.
Hope it helps. All the best!
Put this file into WWW folder of a WAMP-SERVER
then try localhost/yourFileName.php