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 #179648 is a reply to message #179643] Thu, 15 November 2012 16:18 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 11/15/2012 10:21 AM, Thomas 'PointedEars' Lahn wrote:
> 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).
>

So? Actually, it's an advantage. For instance, he may later want to
add PHP code into the menu. He then would not need to go back and
change all his existing code.

>
>
> PointedEars
>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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 13:52:09 GMT 2024

Total time taken to generate the page: 0.04644 seconds