Results 1 to 6 of 6

Thread: How to use return() in PHP?

  1. #1
    Join Date
    May 2009
    Posts
    258

    How to use return() in PHP?

    Hi friends,
    I have done some basic things in PHP programming language. Since I am basic learner, I don't know much about the PHP. So thought will get some help from you guys.!! Please tell me how to use return() in PHP? Any other information about this topic are welcomed. Please reply me as soon as possible.!!

  2. #2
    Join Date
    Mar 2008
    Posts
    672

    Re: How to use return() in PHP?

    If called from a function, the return () function returns immediately and returns the argument passed to it. Return () will also run the command eval () or scripts. In PHP a function is a predefined set of commands that are carried out when the function is called. I would like to explain you about an eval which evaluate a string as PHP code. You must keep in mind that the code passed to eval () must be valid, including the semicolons to end lines and escape sequences, otherwise the execution will end. To mix HTML output and PHP code, you can use a closing tag to leave PHP for PHP mode. Remember that the variables used in the eval () will remain accessible in the main script.

  3. #3
    Join Date
    Aug 2006
    Posts
    227

    Re: How to use return() in PHP?

    If called from the global environment, the script is interrupted. If the current script was include () or require (), then control is returned to the calling script, and the return value is used as a result of the function include (). eval () returns NULL unless return is called in the evaluated code, in which case the value passed to return is returned. In the case of a syntax error in the evaluated code, eval () returns FALSE and execution of the following code continues normally. It is not possible to catch the error analysis of the function eval () function using set_error_handler ().
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

  4. #4
    Join Date
    Jul 2006
    Posts
    442

    Re: How to use return() in PHP?

    If return () is called from the main script, then script execution stops. If the current script is auto_prepend_file and auto_append_file to php.ini. After doing this your script will stop. As with all functions that display the results directly to the browser, you can use the functions of output management to capture the content of this function and save. In the case of a fatal error in the evaluated code, the entire script ends.
    "When they give you ruled paper, write the other way..." J.R.J.

  5. #5
    Join Date
    Jul 2006
    Posts
    286

    Re: How to use return() in PHP?

    If return () is called from the main script, then script execution stops. If the current script is auto_prepend_file and auto_append_file to php.ini, then the script stops.
    • auto_prepend_file string - Specifies the name of a file that is automatically parsed before the main file. This file is included as if it had been with the function require (), so include_path is used.
    • auto_append_file string - Specifies the name of the file that is automatically parsed after the main file. This file is included as if it had been with the function require (), so include_path is used.
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

  6. #6
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to use return() in PHP?

    You should keep in mind that since return () is a language construct and not a function, the parentheses surrounding its arguments are not necessary. It is common to leave them and you should do so as PHP has less work in this case. If no parameter is given, then the parentheses can be omitted and NULL is returned. The call to return () with parentheses but without any arguments will result in a warning analysis. You should never use parentheses around the return variable when returning by reference, because it will not work. You can only return variables by reference, not the result of treatment. If you use return ($ a), then you do not return a variable but the result of the expression ($ a).

Similar Threads

  1. Can I return Ipad2 for new one?
    By Kaesav in forum Portable Devices
    Replies: 1
    Last Post: 13-03-2012, 06:48 PM
  2. SSH return function
    By Elizabeth Allen in forum Networking & Security
    Replies: 5
    Last Post: 22-04-2010, 02:38 PM
  3. Is it possible for a function to return two values?
    By hounds in forum Software Development
    Replies: 5
    Last Post: 13-03-2010, 07:51 PM
  4. How to return an array from function
    By Rilex in forum Software Development
    Replies: 3
    Last Post: 02-10-2009, 09:18 AM
  5. php return multiple values
    By Aston5 in forum Software Development
    Replies: 2
    Last Post: 29-06-2009, 10:14 PM

Tags for this Thread

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
  •  
Page generated in 1,713,481,632.30426 seconds with 16 queries