Page 1 of 1

Beginner Frage

PostPosted: 04. November 2007 21:39
by robertmec
Es tut mir leid aber mein English ist besser dass mein Deutsch!

I created some PHP files (and placed into xampp/htdocs) but the browser reads them like simple text, even if I add a ".php" to the filename.

Danke fuer any info!

PostPosted: 06. November 2007 14:43
by LooseCannon
Hello and welcome robertmec.

I can only do English :( Your's seems great, but we might need some more info.

a. What would you expect the appearance to look like?
b. Are you accessing the page via the web server, eg http://webAdress.local/, or say, double clicking on the file?

When PHP/Apahce _are_ working, they can send simple text/html to the screen, if that's what the code is. Example of a file called index.php:
Code: Select all
<?php lots_of_fancy_php_code_and_functions_and_stuff;
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Not very interesting, simple text</title>
</head>

<body>
<p>This is text and shall appear on the screen<BR>
just as plain text</p>
<?php echo "This is also text, but PHP is producing it";
?>
</body>
</html>


I hope that code's not too crap, because I'm a noob! :lol:

PostPosted: 08. November 2007 02:31
by robertmec
Hi Cannon, thanks for the reply! I'm definitely a "newb" too.

1) I start xampp for windows.
2) My test files are in the directory: C:\xampll\htdocs\TestDir
3) I open a browser at: https://localhost/TestDir and see my test files listed in the browser.
4) The browser is automatically putting a ".txt" extension on each of these simple test files. For example I have a file named "zz" but it shows up as "zz.txt".
5) Now zz just contains the following php code:
<?
echo "Hello there world!";
?>
and when I doubleclick on the filename in the browser, all of this gets displayed as is, as just text. It does not execute the php code and only show me the "Hello there world!" part (which is the kind of behaviour I'm of course after).

6) So I added ".php" to the file name, renaming it "zz.php" and I thought then the browser would execute it as php code, but it still gives the same result.

I know I'm doing, or rather not doing, something simple!

Thanks again for any help.

PostPosted: 08. November 2007 02:42
by Wiedmann
4) The browser is automatically putting a ".txt" extension on each of these simple test files. For example I have a file named "zz" but it shows up as "zz.txt".

No. In the directory listing the browser shows you the real filename. In this case "zz.txt"

But you have configured your Windows Explorer to not show known file extensions. Thus, a file, edited with e.g. "notepad", have automatic the extension "*.txt" ("zz.txt"). But in Explorer you see only the name without extension ("zz").

PostPosted: 08. November 2007 06:39
by Izzy
and when I doubleclick on the filename in the browser, all of this gets displayed as is, as just text. It does not execute the php code and only show me the "Hello there world!" part (which is the kind of behaviour I'm of course after).

You have to open zz.php in your browser by typing in to the address bar a URL (address) and not by double clicking on the file in the directory.
http://localhost/TestDir/zz.php

PHP has to be parsed by the Apache server as PHP is a serverside scripting language.

BTW, to change the Windows Explorer behavior to show file extensions of known types go to:
Control Panel>Folder Options>View>
Untick Hide extensions for known file types
HTH


===========================================
Build Rich AJAX Applications - Faster
TIBCO General Interface Pro Edition but FREE and Open Source
Fully working with NO donations required to get a user/password
===========================================

PostPosted: 09. November 2007 05:03
by robertmec
Thank you very much Wiedmann and Izzy. That works! It was pretty simple. Argh! I am a newbie!