Skip to content
Advertisement

Tag: function

PHP looping through a function before returning value

I have simplified this. I have this line of code in a method in a (codeigniter framework) controller: And this is is the ‘loop1’ function: What I need to be able to do is loop through loop1 function until certain conditions are met before then returning the results array. Problem is calling the function again at the end of loop1

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

Why can’t I use a function to simplify my “for loops”

I build a webpage to crack simple MD5 hash of a four digit pin for fun. The method I used was basically try all combination and check against the MD5 value the user has entered. Below is the PHP code I created to accomplish the goal. Debug Output: Notice that in the middle there are four very similar for loops,I

Advertisement