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

Home » Imported messages » comp.lang.php » echo other way to output a constant?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: echo other way to output a constant? [message #169512 is a reply to message #169503] Thu, 16 September 2010 08:16 Go to previous message
Gordon[1] is currently offline  Gordon[1]
Messages: 6
Registered: September 2010
Karma:
Junior Member
On Sep 15, 5:27 pm, MikeB <mpbr...@gmail.com> wrote:
> Gordon wrote:
>> Doing it this way is making your life harder than it needs to be.  A
>> better approach would be to have a page of basically standard HTML
>> markup and using PHP to inject the values into that.
>
>> The way I'd do it would be to have a PHP file that does all your
>> business logic, and at its last line does an include () of another PHP
>> file that defines how the output should be presented to the users.
>
>> Using this approach, you'd end up with something more along these
>> lines:
>
>> (businesslogic.php)
>
>> <?php
>
>> define ('MAX_FILE_SIZE', 300);
>
>> /**
>>   * The rest of your business logic goes here. Store anything you want
>>   * to use on your page into a variable
>>   */
>
>> include ('page.php');
>> ?>
>
>> (page.php)
>
>> <html><head><title>PHP Form Upload</title></head><body>
>> <form method='post' action='UploadFile2.php' enctype='multipart/form-
>> data'>
>> <!-- MAX_FILE_SIZE must precede the file input field -->
>> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo
>> (MAX_FILE_SIZE); ?>" />
>> Select a JPG, GIF, PNG or TIF File:
>> <input type='file' name='filename' size='60' />
>> <br/><input type='submit' value='Upload' /></form>
>> </body></html>
>
>> Hope you can understand what's going on here.
>
> I think I understand, but I don't see how it's easier and I don't see
> how you will expand that example to include the form processing without
> making it more confusing than it seems to be.
>
> But then I'm new at this, so perhaps I'm missing something?

The advantage of this approach is that it introduces a separation
between business logic and presentation. If you intermingle these two
things then it makes life harder than necessary later down the line
when changes have to be made to either thing. You can even delegate
the presentation side of things to a web designer who doesn't know a
lot of PHP but can turn out really nice looking pages should you
wish :)
[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
Previous Topic: Removing insignificant decimal characters?
Next Topic: Reference # in var_dump output?
Goto Forum:
  

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

Current Time: Wed Nov 27 01:43:18 GMT 2024

Total time taken to generate the page: 0.03881 seconds