Skip to content
Advertisement

Tag: return

PHP function working differently for return and echo. Why?

By using the following class: and Calling the function, by the following code, it works fine. But if in the SafeGuardInput class if I replace echo $finaloutput; with return $finaloutput; and then echo $forminput; on the index.php page. It DOES NOT WORK. Please provide a solution. Answer You can’t return anything from a constructor. The new keyword always causes the

php shorthand return statement

So i was just recently looking for some examples of validating a unix timestamp. One code chunk that kept reappearing was this: Now I have looked for shorthand return if statements which I think this might be but I am not having any luck. can anyone explain to me how this function is deciding what to return and how. Thanks

get return from echo

I’m working with some functions that echo output. But I need their return so I can use them in PHP. This works (seemingly without a hitch) but I wonder, is there a better way? Example: Answer no, the only way i can think of to “catch” echo-statements it to use output-buffering like you already do. i’m using a very similar

Advertisement