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



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.

.



Relevant Pages

  • Re: Migrating a system incrementally. Was: Re: Static vs. Dynamic typing (big advantage or not)
    ... then the run-time behavior is not a mess. ... Suppose you start with XML files, and by Iteration 6 the ... Switching to a database is now cheaper than morphing XML files into a ...
    (comp.object)
  • Re: Migrating a system incrementally. Was: Re: Static vs. Dynamic typing (big advantage or not)
    ... then the run-time behavior is not a mess. ... Suppose you start with XML files, and by Iteration 6 the ... Switching to a database is now cheaper than morphing XML files into a ...
    (comp.programming)
  • Re: Variations and Reuse
    ... books and courses and practical descriptions that have followed. ... Anyway, if "mess B" is such that it allows to modify most parts of the "mess" indendently while "mess A" fails to do so, then "mess B" would IMHO qualify as an improvement upon ""mess A". ... Hard to tell without a better description or definition, but it seems that if rules are somewhat ad-hoc and tends to change frequently, then "kind of like a rules database" could looks like a sensible solution - and probably an "obvious improvement" upon hard-coded rules... ... this is just a relational form of 80's technology Expert Systems. ...
    (comp.object)
  • Re: Restoring database with different COLLATION
    ... > How I can modify the COLLATION of the database after restoring it? ... as SQL Server 2000 supports different collations and sort orders for each ... ALTER DATABASE db_name ... ALTER COLUMN VARCHAR ...
    (microsoft.public.sqlserver.msde)
  • Re: password file on rac
    ... > instance to change the password file otherwise it wouldn't change. ... Database Password and Role Management in Real Application Clusters ... Application Clusters database to authenticate user access to the database. ... Changing the Password--If you alter the password for an existing user, ...
    (comp.databases.oracle.server)