simple php code not been executed - php

I am trying to create a simple php page which contain only an echo, if I saved the page as ".html" it will be opened on google chrome but nothing is executed, if ".php" the page never open. any help? PS: I am new on programing
<html>
<head>
<title> test</title>
</head>
<body>
echo "hello World";
</body>
</html>

You have to write your PHP code between PHP open <?php and close ?> tags.
Try this :
<html>
<head>
<title> test</title>
</head>
<body>
<?php echo "hello World"; ?>
</body>
</html>

Php file don't run .html format and without server . Please read and understand what is php and how it is work ?. follow below link or find youtube tutorial for more visual understanding .
https://www.w3schools.com/php/default.asp
http://php.net/manual/en/
Maybe you try this :
<html>
<head>
<title> test</title>
</head>
<body>
<?php echo "hello World"; ?>
</body>
</html>
Save file as .php format and run through a localhost server that you prefer . if you don't know what is server is
follow link :
https://www.w3schools.com/php/php_install.asp
PHP server on local machine?

Download XAMPP, change your code to
<html>
<head>
<title> test</title>
</head>
<body>
<?php echo "hello World"; ?>
</body>
</html>
Locate the folder C:/xampp/htdocs, and create the file index.php containing your code, now type "localhost" in your web browser and you're done

Related

php isn't processed correctly

Thanks in advance for your help, I am pretty sure you can solve my problem.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>title</title>
</head>
<body>
<?php
echo '<p>hello world</p>';
?>
</body>
</html>
Previous Code example does display
hello world
'; ?>
instead of the expected
hello world
This was run local with xampp V3.2.2 on a win10 OS and Chrome browser.
I hope I'm not the fiftieth person to ask this just because I couldn't google it correctly.
Thanks for your help.

Strange behaviour of php using wamp

I have been using wamp server do build small websites with php for a long time.. but this morning something strange just happend :
here is my home.html file :
<html>
<head>
<title>Test PHP</title>
</head>
<body>
<?php echo '<p>Hello world</p>'; ?>
</body>
</html>
and here is what I get when I display the page :
Hello world
'; ?>
And when I display the source code, here is what I get :
<html>
<head>
<title>Test PHP</title>
</head>
<body>
<?php echo '<p>Hello world</p>'; ?>
</body>
</html>
It seems to be a very stupid problem where the php code is not interpreted by the server.. Any suggestion ?
You saved the filename as .html
Use .php instead of .html it will interrupt.

localhost/test.php returns nothing

I am following a tutorial "PHP & MySQL for dummies" to build a web application. I created a simple test.php file in web space (/var/www/html). The problem is that when I type localhost/test.php in the browser address window, it returns me an empty page. I tried localhost/php.info and it worked well but I could not find why test.php does not work.
This is the test.php code:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>This is an HTML line
<p>
<?php
echo “This is a PHP line”;
phpinfo();
?>
</body></html>
I do appreciate any information.
Thanks.
You said that you put your script in /var/www/html
So the link might be
localhost/html/test.php
Also check the error log file for PHP error.
# cat /var/log/apache2/error.log
EDIT: Change your quote, ” are for Word document and not programming ;-)
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>This is an HTML line</p>
<?php
echo "This is a PHP line";
phpinfo();
?>
</body>
</html>
I have tried with this..just type the word localhost followed with name of the work eg.. localhost/test.php in the navigate bar on your browser then click enter

Php wont execute

When I create file index.php in directory /public/ my source code
<html>
<meta name="ROBOTS" content="NOARCHIVE">
<head><NOFOLLOW><noindex>
<?php echo '123' ?>
</NOINDEX></NOFOLLOW>
</head>
<body>
</body>
</html>
from browser looks like
<html>
<meta name="ROBOTS" content="NOARCHIVE">
<head><NOFOLLOW><noindex>
123
</NOINDEX></NOFOLLOW>
</head>
<body>
</body>
</html>
but if I create folder (no matter where) and place file index.php into it when source code become
<html>
<meta name="ROBOTS" content="NOARCHIVE">
<head><NOFOLLOW><noindex>
if I make some correction in this file, source code stay the same, not changed in browser view.
Why I cant create and run php code where I want, except /public/ folder?
Is that the exact code you are using in both index.php files?
If so, they should both fail as there is a syntax error. You are missing the ; at the end of the php code.
You posted: <?php echo '123' ?>
Should be : <?php echo '123'; ?>
If that´s not the case, you could add the following to the top of index.php to make sure the errors are showing on the page:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
If any error appear after that, please post them back here.

Titanium and PHP - Blank Screen

I am trying to build a desktop PHP app.
<!DOCTYPE HTML>
<html>
<body>
<script type="text/php">
$heading=$document->getElementById("title");
$heading->innerHTML="Now i see you!";
</script>
</body>
</html>
When I launch the desktop app it comes up blank. The basic hello world works fine if I don't try to use php. Am I using the right syntax?
I don't know Titanium, but there is no element with an id of 'title' to set the value of.
Does the following work?
<!DOCTYPE HTML>
<html>
<body>
<script type="text/php">
$heading=$document->getElementById("title");
$heading->innerHTML="Now i see you!";
</script>
<h1 id="title"></h1>
</body>
</html>

Categories