Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #7587

Re: Repetetive code question

Message-ID <7883618.vAuxlELnFz@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2012-11-16 11:24 +0100
Subject Re: Repetetive code question
Newsgroups comp.lang.php
References <s9n9a895m57jed3iclk545cofobh3j728n@4ax.com> <k831fl$vto$2@news.metronet.hr> <1547518.Ru1LMUZkQv@PointedEars.de> <k84sfp$384$1@news.metronet.hr>
Followup-To comp.lang.php

Followups directed to: comp.lang.php

Show all headers | View raw


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.)

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Repetetive code question Dynamo - 2012-11-15 12:26 +0000
  Re: Repetetive code question The Natural Philosopher <tnp@invalid.invalid> - 2012-11-15 12:31 +0000
  Re: Repetetive code question Shake <QUITAESTO@QUITAESTO.NOES> - 2012-11-15 13:33 +0100
    Re: Repetetive code question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-11-15 16:21 +0100
      Re: Repetetive code question Jerry Stuckle <jstucklex@attglobal.net> - 2012-11-15 11:18 -0500
        Re: Repetetive code question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-11-15 21:06 +0100
          Re: Repetetive code question Jerry Stuckle <jstucklex@attglobal.net> - 2012-11-15 16:20 -0500
            Re: Repetetive code question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-11-18 04:53 +0100
              Re: Repetetive code question Jerry Stuckle <jstucklex@attglobal.net> - 2012-11-18 08:38 -0500
          Re: Repetetive code question Jerry Stuckle <jstucklex@attglobal.net> - 2012-11-17 08:54 -0500
  Re: Repetetive code question Jerry Stuckle <jstucklex@attglobal.net> - 2012-11-15 07:47 -0500
    Re: Repetetive code question Dynamo - 2012-11-15 13:21 +0000
  Re: Repetetive code question Goran <goran@nospam.com> - 2012-11-15 16:24 +0100
    Re: Repetetive code question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-11-15 16:36 +0100
      Re: Repetetive code question Goran <goran@nospam.com> - 2012-11-16 09:11 +0100
        Re: Repetetive code question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-11-16 11:24 +0100
  Re: Repetetive code question Christoph Becker <cmbecker69@gmx.de> - 2012-11-15 16:29 +0100

csiph-web