Re: How to escape from a function?

From: Date: Tue, 16 Jan 2001 22:49:45 +0000
Subject: Re: How to escape from a function?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-34913@lists.php.net to get a copy of this message
> say, I have a function like this > function foo() > { > babababa...; > /*at this point, I want to output a lot of html, can I use a ':' to escape > from there?*/ echo '<html>'; echo '<title>chris is great</title>'; return; // would just stop the function OR if you want to call the function from elsewhere like this : echo foo(); or $string=foo(); function foo(){ $html_construct='<html>'; $html_construct.='<title>chris is great</title>'; return $html_construct; } /*I know I can do this is a if construct or for... construct, > but I can't do this at this point*/ /*is there any way for me to do the > similar thing?*/ } not sure about your question. The manual will give escapes for for example switchs parts (break;) and others. See manual part II.11 Control structures. > And I have one more question, what is the meaning of 'or'? > e.g. > $db=mysql_connect("localhost","root","password") or die > ("could not > connect"); In case the command before 'or; fails do what is after 'or'. So if you connect succesfully the script continues, if something goes wrong (wrong password, server down etc etc) the script does die ('bla') this means the script stops and the browsers shows 'bla'. (except when you'r in the middle of building a page and the text is invisible due to its location in the HTML, for example when a table is opened before in Netscape but not closed yet. Chris -------------------------------------------------------------------- -- C.Hayes Droevendaal 35 6708 PB Wageningen the Netherlands -- --------------------------------------------------------------------

« previous php.general (#34913) next »