You are here: Re: Brackets across includes « PHP Programming Language « IT news, forums, messages
Re: Brackets across includes

Posted by Colin McKinnon on 12/17/45 11:56

pengypenguin@gmail.com wrote:

> Hello all,
>
> I am trying to create a user authentication system, and I would like to
> separate the authentication code into include files. As I see it, the
> basic flow would go something like this:
>
> if (not authentic) {
> display login
> } else {
> display content
> }
>
> I would like to separate this code so that the login bit is in an
> included file. I imagined the breakup like this:
>
> file: [auth_head.php]
> -----------------------
> if (not authentic) {
> display login
> } else {
> -----------------------
>
> file: [auth_foot.php]
> -----------------------
> }
> -----------------------

It's ugly, it's messy and it's unmaintainable. Even if you could do it, its
not a good idea. You should apply the same discipline to any HTML fragments
you put in include files - opening and closing tags should match.

A better way of doing this is:

if (! $authenticated()) {
require_once("login.inc");
} else {
require_once("content.inc");
}

There's a lot of reasons for all the changes to your code in the above.

HTH

C.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация