Skip to content
Advertisement

Tag: function

php header location vs php_redirect

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

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

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

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

Advertisement