Ryan Rampersad
Opinions, Thoughts and Ideas - PHP, Java and Javascript
  • Home
  • About
  • Contact
Browse: Home / PHP

PHP

CakePHP 1.3 Helper $text truncate error

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 | Leave a response

Easy CakePHP Database Settings Switching

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 | Leave a response

The State of CakePHP

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 | 4 Responses

Pluralize In Java, Javascript and PHP

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 | 1 Response

Disable CakePHP SQL Log when using Ajax

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 | Leave a response

How to use $javascript->codeBlock in CakePHP

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 | 4 Responses

Hide Email Addresses by Writing Them Out

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 | Leave a response

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

PHP Timer

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 | 6 Responses

Auto Populate a Form with CakePHP

By Ryan on August 14, 2009

Using CakePHP to auto-populate forms is a great way to save your time when developing your applications. Here is an example of some code that isn’t going to auto-populate the form in my view file.

public function edit() {

if ( !empty($this->data) ) {

$this->User->save($this->data);
[...]

Posted in PHP | Tagged cake, form, PHP, populate, tip | Leave a response

Next »

Recent Posts

  • Create a Branch and Switch to it in Git
  • Setting Build Path has Encountered a Problem in Eclipse
  • Queue Ajax Requests in Mootools
  • CakePHP 1.3 Helper $text truncate error
  • CakePHP – 1and1 – 500 Internal Server Error

Tags

(fluff)Grabber 2.7 2009 Apple array beta blog blogs Browser Browsers CakePHP chrome CSS Design Error Firefox fluff friends fluff grabber free Google html iGoogle internet explorer Java Javascript mac Microsoft Mootools music PHP plugin plurk program review School SEO solution string tip Tips update vista Windows windows 7 Wordpress

Search

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
QC: