By Ryan on February 22, 2010
Today I was using one of CakePHP’s helper methods, $text->truncate. It gave me these errors and I can’t say I was pleased about it. It reminded me that sometimes, functions aren’t a piece of cake.
Warning (2): array_merge() [function.array-merge]: Argument #2 is not an array [CORE/cake/libs/view/helpers/text.php, line 184]
Warning (2): extract() [function.extract]: First argument should be an [...]
Posted in PHP | Tagged CakePHP, Error, helper, PHP, truncate
By Ryan on February 19, 2010
I recently deployed a CakePHP application to a 1and1 server. I was presented with a wonderful 500 Internal Server Error. That only means one thing: a .htaccess was messed up somewhere.
There were many places that pointed me in the right direction to fix this problem. It was definitely an annoying hitch. Seriously, there’s that [...]
Posted in PHP, Tips | Tagged 1and1, 500, CakePHP, Error, internal, server
By Ryan on February 16, 2010
CakePHP does make somethings really easy, and sometimes, not so easy. I like to have a testing setting and a production setting stored in my databases.php. Your DATABASE_CONFIG object of course contains those arrays of settings. So the question is, how do you switch exactly?
It is never mentioned specifically in the documentation, but you can [...]
Posted in PHP, Tips | Tagged CakePHP, database, model, PHP, settings
By Ryan on October 23, 2009
I raised some concerns earlier this year by writing the State of the Mootools. This time around, I’m posting about changes to the development team around CakePHP.
The Lithium website is up and running. Check it out. It looks incredible.
Today, the CakePHP world has been rocked. These few short snippets from various blogs around the web [...]
Posted in PHP | Tagged CakePHP, core, developers, lithium, PHP, state
By Ryan on September 17, 2009
I was just reading David Walsh’s post about Possessives. It was a very clever use of PHP. I remembered a helper method I wrote last year that was somewhat similar in use, another form of coding English. It was Pluralization.
At first I just added s if the first argument was not 1 and that won’t [...]
Posted in Java, Javascript, PHP | Tagged Java, Javascript, PHP, pluralize
By Ryan on August 24, 2009
When CakePHP debugging is set to anything above 0, you’re in development mode and it’ll append the sql log on to the end of any view. This is great for general development but if you’re trying to test your ajax functionality, you’ll get that sql log in the ajax response.
I’ve seen some solutions that have [...]
Posted in PHP | Tagged ajax, CakePHP, PHP, sql
By Ryan on August 22, 2009
CakePHP’s $javascript helper is useful but it can be somewhat fickle.
I wanted to throw my javascript into $scripts_for_layout so it’d be in the head of the page. That’s what codeBlock is supposed to do. It seems like you get a couple of usage options. You can write all your javascript as a string and pass it [...]
Posted in Javascript, PHP | Tagged CakePHP, Javascript, PHP
By Ryan on August 20, 2009
I’m totally milking this topic now. If you’ve ever taken a look at the PHP documentation, you’ll know what this means. You’ve probably seen email addresses written out like so:
ryan [dot] rampersad [at] ifupdown [dot] com
That’s really easy to read and it does what it needs to, it stops spammer bots from catching your email [...]
Posted in PHP | Tagged email, hide, out, PHP, write
By Ryan on August 16, 2009
Finally, a post that’s not about a CakePHP problem. I needed to do some quick benchmarking to see if using the PHP port of Dean Edward’s packer was beneficial. I was searching around google for a tiny small timer script but of course, do I find one? No. So I wrote this one. It’s small [...]
Posted in PHP | Tagged class, PHP, script, timer
Hide Email Addresses with HTML Comments
By Ryan on August 18, 2009
When I need to put my email in a public place, I like to hide my email address. One of my favorite ways to hide an email is to use HTML comments.
I wrote this little PHP snippet accepts an email address and breaks it apart with HTML comments.
function hide_email($email) {
$email = trim($email);
$parts = str_split($email, 3);
[...]
Posted in PHP | Tagged comments, email, hide, html, PHP | Leave a response