XAMPP 1.8 PHP problem? [Solved]

Problems with the Windows version of XAMPP, questions, comments, and anything related.

XAMPP 1.8 PHP problem? [Solved]

Postby Ragnarok210 » 15. August 2012 06:42

Hello,
I got this problem in XAMPP 1.8 where php is not show correctly in browser. Apparently, there are couple of people who had this problem as I read other posts. As I did some test myself, I found out that it only happened in the new XAMPP 1.8, thought I am not sure whether it's the PHP 5.4 problem or XAMPP itself.

Here is the script that i tested it with, index.php and LIB.php.
index.php ========================================
Code: Select all
<?php
   require_once 'LIB.php';
   $string = html_header($title="Home",$style = "styles_sheet.css");
   $string .= "<h1>HELLO</h1>";
   $string .= html_footer();
   echo $string;   
?>

LIB.php ========================
Code: Select all
<?
   function html_header($title="Untitled",$styles = "styles_sheet.css"){
      $string =<<<HEAD
      <!DOCTYPE html>
      <html xmlns = "http://www.w3.org/1999/xhtml">
      <head>
         <meta http-equiv = "content-type" content="text/html;charset=utf-8" />
         <title>$title</title>
         <link type = "text/css" rel= "stylesheet" href = "$styles" />
      </head>
      <body>
HEAD;
      return $string;
   }
   function html_footer(){
      $string =<<<FOOT
         </body>
         </html>
FOOT;
      return $string;
   }
?>

==================================================

In XAMPP 1.7.7, it works fine... which's it shows "Hello" in h1 tag.
in XAMPP 1.8.0, here is the result...
Image

When you run even simpler code such as <?php echo "hello"; ?> it work fine, phpInfo() work fine too..

note: I tried reinstalling, didn't work either. I view the file through server localhost, and not directly on computer. I did install the microsoft c++ 2008 32bit.

Any help would be appreciated, Thanks in Advance...

[EDIT by Altrea: added code-BBTags around code. Please next time add them on your own.]
Ragnarok210
 
Posts: 9
Joined: 15. August 2012 03:47
Operating System: Window 7

Re: XAMPP 1.8 PHP problem?

Postby adi06 » 15. August 2012 09:45

What do u mean by :
I got this problem in XAMPP 1.8 where php is not show correctly in browser.

What is not showing correctly?
And ur provided pic is not here anymore...
adi06
 
Posts: 8
Joined: 06. September 2009 10:50

Re: XAMPP 1.8 PHP problem?

Postby JonB » 15. August 2012 15:21

Is it possible you have short_open_tag off? :shock:

Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: XAMPP 1.8 PHP problem?

Postby Ragnarok210 » 15. August 2012 16:40

The picture there is showing the problem (the picture is still there O.O) displaying the php page in XAMPP 1.8.0.
@adi06 I mention the script work in XAMPP 1.7.7. Which is showing <h1>Hello</h1> in browser. It works fine in XAMPP 1.7.7, which's php version 5.3.8 I believe.
Both used the same script.

@JonB I triple checked, there's no short_open_tag or any syntax error.
Ignoring that LIB.php script there. If you replace it with ----->
Code: Select all
<? php
function html_header(){
            echo "This is in LIB.php";
}
function html_footer(){
            echo "Hello from footer";
}

It doesn't work either.

note: What I use originally was the Heredoc syntax, I thought that was causing the problem. Apparently it's not.
Thanks for responding...
Ragnarok210
 
Posts: 9
Joined: 15. August 2012 03:47
Operating System: Window 7

Re: XAMPP 1.8 PHP problem?

Postby JonB » 15. August 2012 16:56

when you run this code - what is the output?

Code: Select all
<? php
function html_header(){
            echo "This is in LIB.php";
}
function html_footer(){
            echo "Hello from footer";
}


8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: XAMPP 1.8 PHP problem?

Postby Altrea » 15. August 2012 17:52

Seems to me like your HEREDOC string blocks are not terminated correctly.
Do you have any invisible whitespaces in front of your HEAD; line?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8290
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: XAMPP 1.8 PHP problem?

Postby Altrea » 15. August 2012 17:57

Forget what i said before. Of cause JonB is correct.
short_open_tags are setted to Off by default in the current version 8)

Ragnarok210 wrote:Ignoring that LIB.php script there. If you replace it with ----->
Code: Select all
<? php
function html_header(){
            echo "This is in LIB.php";
}
function html_footer(){
            echo "Hello from footer";
}

It doesn't work either.


There is a space between <? and php. Sure, this will not work, because it is still a short open tag.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8290
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: XAMPP 1.8 PHP problem?

Postby Ragnarok210 » 15. August 2012 18:40

Ah I just figure it out as I type this. Apparently, php document still works in 5.3.8 if you leave out the <? (php), but not in 5.4.

Thanks for the help...
Ragnarok210
 
Posts: 9
Joined: 15. August 2012 03:47
Operating System: Window 7

Re: XAMPP 1.8 PHP problem?

Postby JonB » 15. August 2012 18:54

ah yes - that would be SHORT OPEN TAG :shock:

its a setting in php.ini edited (that will now not work quite the same way)

8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: XAMPP 1.8 PHP problem?

Postby Ragnarok210 » 15. August 2012 19:17

Yea, I guess you were right, funny thing is now I checked the short_open_tag, the default was On O.o?, So I turn both development value and production value to On (even thought i am not sure what they do), then restart the apache server. It still doesn't work with <?, but whatever I am satisfy, doesn't hurt adding extra 3 letters.

Thanks again...
Ragnarok210
 
Posts: 9
Joined: 15. August 2012 03:47
Operating System: Window 7

Re: XAMPP 1.8 PHP problem?

Postby JonB » 15. August 2012 20:50

That is because of a change - to clarify/avoid problems with xml -

http://stackoverflow.com/questions/8004 ... g-open-tag

Good explanation:

http://programmers.stackexchange.com/qu ... tag-in-php

Good Luck
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: XAMPP 1.8 PHP problem?

Postby Altrea » 16. August 2012 03:40

Ragnarok210 wrote:funny thing is now I checked the short_open_tag, the default was On O.o?, So I turn both development value and production value to On

funny thing, you don't changed the setting. What you have changed are just comments what settings are common for some environments. This are just examples.
The real setting don't have a semicolon in front of the line.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8290
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 43 guests