2019-09-21 04:00:20

So I'm not asking for a tutorial here. The matter is much more trivial.
I have tried to get PHP onto my machine without success. I have tried tools like xampp, which was partially accessible, I have managed to launch it, start up a php server, but here's where my problems come in:
Consider this code:

<!DOCTYPE html>
<html>
<head>
<title>PHP test</title>
</head>
<body>
<?php
echo "Hi!";
>
</body>
</html>

Maybe it's the code, maybe it's something else, but ur... that doesn't work when I go and try it with xampp.
So, my question is, how? How would one run php?
I don't want to use a free host out there... Uploading files just to fix an error is a bit too absurd, I want to test it on my machine and only upload when I verify that everything works successfully.
Suggestions/tips?

2019-09-21 08:42:28

You can run a php server from the command line. I believe the command is php-server:4000, if i remember correctly. If not, let me know.
Hope this helped.

2019-09-21 09:20:32

Your code isn't correct.
Try this:

<?php
phpinfo();
?>

If you see all the information about your PHP version and etc, then it works like a charm.

2019-09-21 15:10:28 (edited by amerikranian 2019-09-21 15:11:22)

@2:
php-server, when typed in the command line, yields nothing.
@3:
Ironically, if I go and try going to localhost/dashboard/phpinfo.php, everything works. However, if I copy the same line from the php file, the phpinfo thing, it won't work in my indx.html, no it's not a tipo. Here's my code:

<!DOCTYPE html>
<html>
<head>
<title>PHP test</title>
</head>
<body>
<?php
phpinfo();
?>
</body>
</html>

I tried typing the php statement on one line and nothing... the only thing it shows is my html title statement. Tips and suggestions would be greatly appreciated.

2019-09-21 17:26:00

@op, I use xampp, and it works like a charm.

Here is my process:

In c:\xampp\hdocx make your files.

File: Index.php:

<!doctype html> <html> <head> <title>Php Test.</title> </head> <body>
<?php
phpinfo
?>
</body> </html>

Then, run http://localhost in your web browser. Note! It can not! Be https, it is not a secure server, and doesn't run with the appended s.

Let me know if this works.
hth.

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2019-09-21 19:49:20

Yeh so... I was being an idiot. I didn't realize that .html will not be treated as .php. I also didn't know the fact that html can be inside a .php file. Oh well, lesson learned, I suppose.

2019-09-21 23:50:36

@6 mwaha, I also learned that the hard way.

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2019-09-22 08:59:01

It's just your extension of the file wasn't accepted by the PHP interpretator. Of-course you can force your server to recognise .html extension as such, however I think there it wasn't the main problem.
I suggest you to use wamp server, because there management is easy enough. Put your files in www directory and run by using browser, keep in bind tthat there is port 80 that http server uses, so Syke or some other apps that could overtake the port might be beyond. However php it's really straightforward to use if you know other scripting languages.