Skip to content

Tag: php

How to disable PHP Error reporting in CodeIgniter?

I’ve read the official documentation and all they say is that I should have a error_reporting() function located at the top of your main index.php file. But I don’t have index.php file in my project. My base controller is called core so to get to main index I go to www.mysite.dom/core/. So I guess…

How to display a readable array – Laravel

After I write: And after I refresh the browser I get an unreadable array. Is there a way to get that array in a readable format? Answer dd() dumps the variable and ends the execution of the script (1), so surrounding it with <pre> tags will leave it broken. Just use good ol’ var_dump() (or print_r…

How do I traverse CakePHP relations?

I’m trying to traverse the relations on CakePHP models. This is the database: I can access product attributes (product->attributes) on a product model but I cannot access the product attributes on Ad model (ad->product->attributes). Here is my code: And here is what I do in the views: What is w…

Warning: preg_replace(): Unknown modifier

I have the following error: Warning: preg_replace(): Unknown modifier ‘]’ in xxx.php on line 38 This is the code on line 38: How can I fix this problem? Answer Why the error occurs In PHP, a regular expression needs to be enclosed within a pair of delimiters. A delimiter can be any non-alphanumeri…

Laravel default orderBy

Is there a clean way to enable certain models to be ordered by a property by default? It could work by extending the laravel’s QueryBuilder, but to do so, you’ll have to rewire some of it’s core features – bad practice. reason The main point of doing this is – one of my models ge…