FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Repetetive code question
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Repetetive code question [message #179656 is a reply to message #179655] Fri, 16 November 2012 10:24 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
Goran wrote:

> On 15.11.2012 16:36, Thomas 'PointedEars' Lahn wrote:
>> Goran wrote:
>>> On 15.11.2012 13:26, Dynamo wrote:
>>>> Not sure if this is the right place to ask this question as it is more
>>>> an html query than a php one but here goes anyway.
>>>>
>>>> I have a large chunk of html code that is used to build an extensive
>>>> drop down menu. The same code is used on all 30 of my web pages. So I
>>>> have seperated the code into a txt file called menu.txt and used the
>>>> following php code to get the file contents:
>>>> [
>>>> <?php
>>>> $mymenu=file_get_contents('menu.txt');
>>>> echo $mymenu;
>>>> ?>
>>>> ]
>>>> Everthing works fine but is this good practice and is there a better
>>>> way.
>>>
>>> This should be:
>>>
>>> <?php readfile('menu.html') ?>
>>
>> How do you know this is not an example and they want to process the file
>> contents before writing it to the standard output?
>
> How do I know? Because he wrote it (implicitly) - he already
> successfully use "file_get_contents" (this function does not process
> local files) + his menu template is called ".txt".

You are overlooking the possibility that `echo $mymenu;' is not the next
statement.

>> And there appear to be issues with readfile(), enabled output buffering
>> and large files or slow connections. Not so with file_get_contents();
>
> Somehow I don't think simple menu template will cause memory issues.

You are jumping to conclusions again.

> Guys, stop reinventing the wheel, readfile() is made for this in the
> same way as include() is made for including other php skripts.

readfile() is made for this if, and only if, the file content should be
written verbatim to the standard output and none of the mentioned issues
arise. Your ignoring them does not make the possibilities disappear.


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Scrape dynamically generated hyperlinks
Next Topic: PHP 5.5 and Windows XP
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 15:51:06 GMT 2024

Total time taken to generate the page: 0.04218 seconds