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.
Related
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
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.
Recently I found preg_match giving different results when the PHP-code is inside a .html-file or a .php-file!
It seems like it has something to do with the RegEx-Modifier "/u". When this flag is set and inside the teststring is an unicode-character(like the "Ö" in the examples),
it will give different results.
Does anyone have an idea why this could be?
Example 1 - .html-file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<?php
$test="asdddddAÖ";
echo preg_match('/^[[:print:]\s]*$/u', $test);
?>
</body>
</html>
Example 1 - Output:
0
Example 2 - .php-file
<?php
$test="asdddddAÖ";
echo "
<!DOCTYPE html>
<html lang=\"en\">
<head>
<meta charset=\"UTF-8\">
<title>Document</title>
</head>
<body>
".preg_match('/^[[:print:]\s]*$/u', $test)."
</body>
</html>";
?>
Example 2 - Output:
1
If I delete the unicode-character from the teststring the result of both is
1
which I expected.
Also if I delete the /u-Flag from the RegEx the result of both is
0
as expected too.
Both examples ran under the same apache-instance with php 5.6.24. And both files were encoded UTF-8 in the editor. It is also an Plesk 12 environment on Ubuntu 14.04 if that helps.
I'm using Smarty with CodeIgniter.
Here's my code:
<!doctype html>
<html lang="en-gb">
<head>
<title>Frustrating as Hell</title>
<meta charset="utf-8">
</head>
<body>
{if $test == 'hello'}
Hello!
{/if}
</body>
</html>
If I view-source on Chrome, I see this (removed unnecessary parts):
<body>
Hello!
</body>
I want it to be nested correctly like so:
<body>
Hello!
</body>
How would I do this? Please don't suggest {strip}{/strip}, that outputs <body>Hello!</body> which I don't want.
Thanks!
I don't really understand why you would want it to look good in chrome's view-source but if I were you, I'd play around with the source
<!doctype html>
<html lang="en-gb">
<head>
<title>Frustrating as Hell</title>
<meta charset="utf-8">
</head>
<body>{if $test == 'hello'}
Hello!{/if}
</body>
</html>
I don't know if this will work, but either way, you will end up having your working code not neat or the result not neat. If I had choice, I'd chose the resulting code not neat, because in fact nobody will look at it (well I guess) ;-)
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>