SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast morrty's Avatar
    Join Date
    Oct 2008
    Location
    Ontario, Canada
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    array inside exit() function?

    Just wondering if this is good practice or not? It seems to work but I couldn't find anything on this:

    Code:
    			
    if(!@mysql_connect('localhost', 'user', 'password')) {        //Connect to Server
    	exit($error[] = '<p>Unable to connect to the database server</p>');
    } else {
    	if(!@mysql_select_db('dbname')) {        //Select Database
    		exit($error[] = '<p>Unable to select database.</p>');
    	}
    }
    I want to do it this way so I can have all errors echo'ed in an errors section on the page.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    exit() is going to end execution of your program, you won't be able to access those arrays in later code

    Don't call exit() at all, just set the arrays

  3. #3
    SitePoint Member
    Join Date
    May 2009
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    exit — Output a message and terminate the current script


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •