In a previous ticket i asked about logging PHP errors in MySQL which gives me: I can make this work but only if it is triggerred like this: However, I also want the error handler to be called for all errors such as syntax errors like: But these errors are just outputted to the screen, what am i doing wrong?
Tag: php
PHP code for generating decent-looking coupon codes (mix of letters and numbers)
For an ecommerce site I want to generate a random coupon code that looks better than a randomly generated value. It should be a readable coupon code, all in uppercase with no special characters, only …
PHP Append to empty string without error
I have got the following issue, my function appends code to a string $string ($string .= bla), but in the beginning the string is empty, so I get this error message A PHP Error was encountered Severity: Notice Message: Undefined variable: $string Filename: libraries/file.php Line Number: 90 Of course if I def…
Print the keys of an array
I could not figure out how to pass a variable number of variables into a function. I thought passing in an array and using the array keys for the variables names could replace the need to pass extra variables into the function, and it worked (I’m sure there is a better way to accomplish this, suggestion…
Check and return duplicates array php
I would like to check if my array has any duplicates and return the duplicated values in an array. I want this to be as efficient as possible. Example: Also the initial array is always 5 positions long Answer this will be ~100 times faster than array_diff
How to generate unguessable “tiny url” based on an id?
I’m interested in creating tiny url like links. My idea was to simply store an incrementing identifier for every long url posted and then convert this id to it’s base 36 variant, like the following in PHP: The problem here is that the result is guessable, while it has to be hard to guess what the …
Add spaces between words in a camelCased string then uppercase the first word
I have two types of strings, hello and helloThere. What I want is to change them so they read like: Hello and Hello There depending on the case. What would be a good way of doing this? Answer you can use ucwords like everyone said… to add the space in helloThere you can do $with_space = preg_replace(…
CodeIgniter without a Database?
Sorry if this is a simple question, is it possible to load codeigniter without a db setup? I have sess_use_db set to false in the config, I tried renaming database.php to something else but it still wants to load it, I turned active records off also. I tried commenting everything out in the database.php and i…
two values for one name in input
I have one input (type radio) that I want to insert it 2 values, something like that: And after draw each value seperated …
echo key and value of an array without and with loop
This is an array i have How do i get to echo something like this for individual one like and again how can i do this through a loop and echo all? Answer For ‘without loop’ version I’ll just ask “why?”