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


Groups > comp.lang.php > #7576

Re: Repetetive code question

From Christoph Becker <cmbecker69@gmx.de>
Newsgroups comp.lang.php
Subject Re: Repetetive code question
Date 2012-11-15 16:29 +0100
Organization Aioe.org NNTP Server
Message-ID <k831p7$i3m$1@speranza.aioe.org> (permalink)
References <s9n9a895m57jed3iclk545cofobh3j728n@4ax.com>

Show all headers | View raw


<Dynamo> wrote:
> [
> <?php
> $mymenu=file_get_contents('menu.txt');
> echo $mymenu;
> ?>
> ]
> Everthing works fine but is this good practice and is there a better
> way.

The equivalent to echo file_get_contents('filename') is
readfile('filename').  The benefit over file_get_contents() is, that it
doesn't need to load the complete file into memory.  The benefit over
include() & al. is, that it's faster, as the file doesn't have to be parsed.

-- 
Christoph M. Becker

Back to comp.lang.php | Previous | Next — Previous 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