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 –> Manual for HTTP_redirect https://php.net/manual/en/function.header.php –> Manual for the function header Answer http_redirect is basically a helper function, making it easier to use header location by allowing
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 misunderstanding something fundamental here – can anyone help please. here’s
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 abbreviation more precise. I have a number, e.g. 1000, 1230,
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. The latter is not visible outside
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 what does UCS-4BE mean? Answer You might
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 having to reinvent the wheel when something
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 this function to simplify counting rows mysql rows for banned members, inactive members etc, since all will be
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=0, $type=’name’) getting error message How can I
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(“…