PDA

View Full Version : Include a file.


Morgoth
08-13-2002, 06:59 PM
I don't know PHP;

There is a way in ASP to include a file, how do I include a file in PHP?

mordred
08-13-2002, 07:03 PM
You go to www.php.net and type "include" in the search engine.

Socraties
08-13-2002, 07:39 PM
To include a file in php you use this



<?

include ("Filename.fileextension");

?>

redhead
08-13-2002, 08:33 PM
as Socraties stated, but remember it needs

<?php include('file.ext'); ?>

:thumbsup:

Spookster
08-13-2002, 09:41 PM
Originally posted by redhead
as Socraties stated, but remember it needs

<?php include('file.ext'); ?>

:thumbsup:

I'm assuming that you are referring to the lack of the word php in Socrates' post.

Actually that is a valid way of starting a php script. That is referred to as short tags and will work as long as that option has been enabled in the php configuration. There are also two other ways as stated in the manual:

http://www.php.net/manual/en/language.basic-syntax.php

Morgoth
08-14-2002, 10:44 AM
Originally posted by mordred
You go to www.php.net and type "include" in the search engine.

Just so you know, I think when a person asks a question as simple as this, I think it would just be easier for the both if it was given as a straight answer.
But Thanks anyways.


Thank you also to the others that replied.

mordred
08-14-2002, 11:56 AM
Why would that be easier for me? I thought my answer was pretty straight though; if I were a complete newbie, it would have led me very fast to a resource that should answer any initial questions about including files. I don't believe you would have prefered a plain "RTFM" instead.

Morgoth
08-14-2002, 12:17 PM
"I don't know PHP." I stated that in the begining, and I didn't say anything about learning php.
I just needed a single script for a friends server.

It would of been very easy for me to just have it right off the bat, and not have to look for it myself (Seeing how I don't know PHP nor how to read it.)

It's good that you gave a resouce, but could you not of just said:

<?php include('file.ext'); ?>

You can find this code and many other answers to basic php from http://php.net


I don't want to start and argument

mordred
08-14-2002, 01:07 PM
I don't perceive your comments as starting an argument, it's just that we have different opinions how to answer questions in this forums. Since the description of it is


PHP has emerged as one of the most robust, popular server side languages on the web. Discuss PHP scripting here.


So I automatically perceive those who participate in this forum as people who want to learn and use php. Yes, I could have answered the question like you posted, but I firmly believe it's more effective in the long run to provide people with ways how they can solve the solution themselves (and related questions in the future).

Just in case you didn't know, in the devshed forums, there is a slight antipathy against people who just ask for code. Same is true for certain newsgroups.
This board does not have to develop a similar attitude, but still one more point: When questions like yours and the corresponding answers you described came to dominate this forum, I'll bet that things get boring to regulars. Such a board would slowly transform from a discussion board to a support forum IMHO.

Morgoth
08-14-2002, 02:19 PM
Originally posted by Morgoth
I don't want to start and argument

Spookster
08-14-2002, 02:24 PM
Alright you two knock it off or I will close the thread.