Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7574
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news1.tnib.de!feed.news.tnib.de!news.tnib.de!news.bawue.net!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <1378142.Krg0msSpID@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <php@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Thu, 15 Nov 2012 16:21:18 +0100 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 8Bit |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: Repetetive code question |
| Newsgroups | comp.lang.php |
| References | <s9n9a895m57jed3iclk545cofobh3j728n@4ax.com> <k82nev$nke$1@dont-email.me> |
| Followup-To | comp.lang.php |
| MIME-Version | 1.0 |
| Lines | 50 |
| NNTP-Posting-Date | 15 Nov 2012 16:21:19 CET |
| NNTP-Posting-Host | 7181c699.newsspool1.arcor-online.net |
| X-Trace | DXC=U2C<1Io_o8l<6cDJZfMd_cic==]BZ:afn4Fo<]lROoRankgeX?EC@@`1CEWAg0_HNeDZm8W4\YJNlJ`:FmdeL>K`MbG5PB_J>1ln>nF^_CM4^i |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.php:7574 |
Followups directed to: comp.lang.php
Show key headers only | View raw
Shake wrote:
> El 15/11/2012 13:26, Dynamo escribió:
>> 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.
>
> if the content of 'menu.txt' is HTML... the filename should be
> 'menu.html'.
And the variable is superfluous (except perhaps for debugging):
<?php
echo file_get_contents('menu.txt');
?>
> What you are doing is an include... you can do this way:
>
> <?
> include('menu.txt');
> ?>
That is not equivalent to the above, because with `include' (or
`include_once', `require', or `require_once') the content of menu.txt will
be parsed (searched for <?php … ?> sections which will then be executed).
[I had stumbled over that difference while writing a code compactor for
ECMAScript-based scripts and Cascading Style-Sheets. It turned out that
some of the stylesheets contained `<?' verbatim intentionally (property
values were generated by PHP), and one test ECMAScript-based script
contained it by accident in a regular expression. Because the compactor
(PointedEars' Resource Builder) had to be able to process those resources
even with short_open_tag=1, the regular expression in the ECMAScript-based
script had to be split up. See
<http://PointedEars.de/websvn/filedetails.php?repname=JSX&path=%2Ftrunk%2Fbuilder.php>
for details.]
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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