Having trouble with PHP

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

Having trouble with PHP

Postby sammydog » 03. March 2006 11:54

Ok, I'm pretty new to PHP, but hopefully someone can help.
I have file getbackendinfo.php which looks like this:
$out = "O\n" .
"H\tver\tnow\n" .
"D\t0.1\t" . time() . "\n" .
"H\tid\tkit\tname\tdescr\n" .
"D\t11\t0\tChsht_protecta\tProtecta shotgun with slugs\n" .
"D\t22\t1\tUsrif_g3a3\tH&K G3\n" .
"D\t33\t2\tUSSHT_Jackhammer\tJackhammer shotgun\n" .
"D\t44\t3\tUsrif_sa80\tSA-80\n" .
"D\t55\t4\tUsrif_g36c\tG36C\n" .
"D\t66\t5\tRULMG_PKM\tPKM\n" .
"D\t77\t6\tUSSNI_M95_Barret\tBarret M82A2 (.50 cal rifle)\n" .
"D\t88\t1\tsasrif_fn2000\tFN2000\n" .
"D\t99\t2\tsasrif_mp7\tMP-7\n" .
"D\t111\t3\tsasrif_g36e\tG36E\n" .
"D\t222\t4\tusrif_fnscarl\tFN SCAR - L\n" .
"D\t333\t5\tsasrif_mg36\tMG36\n" .
"D\t444\t0\teurif_fnp90\tP90\n" .
"D\t555\t6\tgbrif_l96a1\tL96A1\n";

print $out . "$\t" . strlen($out) . "\t$";

?>

should return this in browser:
O
H ver now
D 0.1 1140968114
H id kit name descr
D 11 0 Chsht_protecta Protecta shotgun with slugs
D 22 1 Usrif_g3a3 H&K G3
D 33 2 USSHT_Jackhammer Jackhammer shotgun
D 44 3 Usrif_sa80 SA-80
D 55 4 Usrif_g36c G36C
D 66 5 RULMG_PKM PKM
D 77 6 USSNI_M95_Barret Barret M82A2 (.50 cal rifle)
D 88 1 sasrif_fn2000 FN2000
D 99 2 sasrif_mp7 MP-7
D 111 3 sasrif_g36e G36E
D 222 4 usrif_fnscarl FN SCAR - L
D 333 5 sasrif_mg36 MG36
D 444 0 eurif_fnp90 P90
D 555 6 gbrif_l96a1 L96A1
$ 473 $

not exactly like that but hopefully you get the idea, but instead the browser returns this:

O H ver now D 0.1 1141382685 H id kit name descr D 11 0 Chsht_protecta Protecta shotgun with slugs D 22 1 Usrif_g3a3 H&K G3 D 33 2 USSHT_Jackhammer Jackhammer shotgun D 44 3 Usrif_sa80 SA-80 D 55 4 Usrif_g36c G36C D 66 5 RULMG_PKM PKM D 77 6 USSNI_M95_Barret Barret M82A2 (.50 cal rifle) D 88 1 sasrif_fn2000 FN2000 D 99 2 sasrif_mp7 MP-7 D 111 3 sasrif_g36e G36E D 222 4 usrif_fnscarl FN SCAR - L D 333 5 sasrif_mg36 MG36 D 444 0 eurif_fnp90 P90 D 555 6 gbrif_l96a1 L96A1 $ 473 $

do I have a setting wrong that is not letting it display php files correctly?
Thanks for any help, I'm using xampp 1.4.16
sammydog
 
Posts: 2
Joined: 03. March 2006 11:38

Postby Wiedmann » 03. March 2006 12:07

With "\t" you got only a tab in a textfile (text/plain). But a Browser use "text/html" to show the data, if you don't change the content-type or ise something like a pre-tag in html.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby sammydog » 03. March 2006 12:24

actually its not an .php its a .aspx, but in htdocs I have file .htaccess which says:
AddType application/x-httpd-php .aspx
IndexIgnore *

also have <?php at beginning of .aspx files

Ok, I fixed that file by adding <PRE> </PRE> to beginning and end
but is there a way to have it treat all files like this instead of putting tags in them?
sammydog
 
Posts: 2
Joined: 03. March 2006 11:38

Postby Wiedmann » 03. March 2006 12:54

I try it a second time...

If you open a page with your browser, the browser want have a valid html file from the server. It doesn't matter if the extension is aspx or html or php or xyz. The only important thing is the content-type the server send to the browser for this page. And for a PHP script the content-type is text/html. And so the browser uses the html rules for parsing the page.
--> in html a tab have no special funktion, it's only a space.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 119 guests