Reply to Re: Returning from an included script while inside a function ?

Your name:

Reply:


Posted by joe on 02/03/06 04:28

Thanks for the answer !

If there is a double quotation of your reply - I apologize. I am using
google groups interface, and it appears it won't let me use 'broken'
quotes.

> In my tests this works as expected, but why not make sure by having the
> included file contain a function?

Yep - I already have a function in the included file :)

> Well I know this is awful practise
> and might not actually be viable with what you have

Not sure I agree it's an awful practise. I have often used 'utility'
include files that included functions that simplified things I had to
do often.

Also if you do objects - including is a must, otherwise the
practicality of seperating business logic from the objects is lost :)

Your first example would work, but alas it is not viable in my
situation. I am fixing someone elses work, and it's a mess. Totally
sequentially written - then we do this - then we do this. The main file
is index.php and it branches execution to various include files with a
switch statement. It is in fact the only file that is ever called
directly in this system. If I alter the main file - I alter
functionality for a ton of other files, which I'd then have to re-edit
and bugtest.

Right now I am fixing the search_inc.php file, in which various
database calls is scattered all over a mess of 'if(thisorthat) then we
construct this horrible SQL and add that HTML' code. In order for
sanity to prevail, I am arranging things nice and neatly into
functions. I can do this within this include file, but I dare not
venture into any changes that might rock the rest of the system.

Another reason is that the databasefunction is called from other
functions - so I'd have to do an error check after all calls (which is
what I'll end up doing anyway as pr. aschrage16's suggestion) - so
even if I overwrite $output, new content (like end of tables that are
no longer there) will be generated, rendering that whole exercise
obsolete.

At any rate - the problem is not an obstacle, I just thought that since
there IS an 'escape' mechanism for an included file (a return statement
in the global scope), it's odd and a bit annoying that you can't
invoke that mechanism from inside a function.

[Back to original 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

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