Page 1 of 1

PHP problem

PostPosted: Tue Jul 24, 2012 3:02 pm
by BlackSundayHacker
Hi guys,
A few days ago I started to learn PHP, I set up a XAMPP test server and I have a problem... When I try to print PHP text it doesn't show anything, the page is blank... I searched everywhere but I cant find solution for this problem :cry:
Here are some samples:
Code: Select all
<html>
   <head>
      <title></title>
   </head>
   <body>
      <h1>Test!</h1>
   <?php
      print("Hi!");
   ?>    
</body>
</html>

This shows only: Test!
Another sample:
Code: Select all
      <?php
         print("<h1>Test</h1>");
      ?>

Result: Test"); ?>

Any help wold be greatly appreciated, BlackSundayHacker.

Re: PHP problem

PostPosted: Tue Jul 24, 2012 5:07 pm
by mShred
Copied and pasted your code, it works on my own server. That said, I would use echo() rather than print() for something this simple. But in regards to your situation, your setup must have something wrong with it. Your PHP must not be working. How do you have it set up?

Re: PHP problem

PostPosted: Tue Jul 24, 2012 6:57 pm
by LoGiCaL__
Same here, code ran fine.

Does your files have a .php extension?

-- Tue Jul 24, 2012 7:16 pm --

That looks to be your problem if everything is setup on the server correctly. Rename your files with a .php extension instead of a .html. I was able to duplicate both results by having a .html extension with your supplied code.

Re: PHP problem

PostPosted: Thu Jul 26, 2012 11:01 am
by BlackSundayHacker
I found my problem, everything was ok, just I was opening my page from HDD not localhost. :)
Thanks for the help anyway.

Re: PHP problem

PostPosted: Thu Jul 26, 2012 4:09 pm
by mShred
Ah, makes sense. You have to route through apache for the PHP script to be recognized.
Topic = SOLVED