What’s the difference between the function “HTTP_redirect” and “header location” in PHP ? When must I use the function “HTTP_redirect” ? When must I use the function “header location” ? Look that: https://php.net/manual/en/function.http-redirect.php –…
Tag: function
understanding why echo doesnt work within a php class function
I’m trying to debug a class and using print_r and echo to view the variables as the script progresses. However for some reason I can’t seem to get any output from within the function, i’ve declared the function public but can’t get any output using print, echo or print_r. I’m mis…
PHP number abbreviator
Edit: Function below now does the abbreviation correctly, implemented @Asad ‘s solution Hi I am currently working on a like button, I’ve got all the base functionality working nicely however I have started the number abbreviation code and hit a wall as I can’t figure out how to make the abbr…
PHP Function to return string
I am fairly new to PHP. I have a function which checks the cost of price. I want to return the variable from this function to be used globally: Answer You should simply store the return value in a variable: The $deliveryPrice variable above is a different variable than the $deliveryPrice inside the function. …
Searching for a good Unicode-compatible alternative to the PHP ord() function
After quite a bit of searching and testing, the simplest method I’ve found for a Unicode-compatible alternative to the PHP ord() function is this: I found this here. However, it has been mentioned that this method is rather slow. Does anyone know of a more efficient method which is nearly as simple? And…
explode an array of delimited strings into two arrays
I have the following array: that I need to split into two arrays using “-” as delimiter: and Is there anything like array_explode that does what I want? or a combination of php array functions? I’d like to do this without going through my own for/each loop, if possible, or at least minimize …
How to truncate a string in PHP to the sentence closest to a certain number of characters?
I want to truncate/shorten my string to the sentence closest to a ceratain number of characters. I have a working function, but my function truncate to the word closest to a certaion number of …
Function to count MySQL rows using WHERE
am making function to count rows using “WHERE”, but i get a mysql error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:AppServwwwtesttestindex.php on line 9 Unknown column ‘1’ in ‘where clause’ here is my function i’ve created t…
PHP function missing argument error
My validate function looks like that Function call example As you see, my validate function has 3 input vars. I’m not using second var – $data2 often, that’s why set it to 0 by default. But when I’m calling this function as given example (as far as I know it means $data=$lname, $data2=…
Why does PHP not throw an error when I pass too many parameters to a function?
I am a n00b at php. I was learning about Default Parameters so I made this function. function doFoo($name = “johnny”){ echo “Hello $name” . ““; } I made these calls doFoo(); doFoo(“…