php

recent posts related to the php programming language

CakePHP find conditions (plus find all, find list, and find count)

CakePHP find FAQ: Can you share some "CakePHP find conditions" examples?

One thing you need to get used to when working with CakePHP is the CakePHP find method. To that end, I thought I'd put together this page of CakePHP find conditions and find query examples.

CakePHP find conditions

To get started, here's a list of the possible CakePHP find conditions you can use:

CakePHP Auth login - User login information

CakePHP Auth user login FAQ: Help, how do I get access to the CakePHP user object (user information) after using the CakePHP Auth component for the recommended CakePHP user login process?

A CakePHP user registration form example

CakePHP user registration FAQ: The cookbook covers the topic of CakePHP user login forms, but the CakePHP Auth module uses SHA1 for passwords, and the cookbook doesn't cover user registration (creating users, and SHA1 passwords); how do I set up a CakePHP user registration form, including all necessary CakePHP model, view, and controller classes?

Setting up a basic CakePHP registration form isn't too hard, er, well, once you know how to do it. Here's how.

CakePHP - Warning - Cannot modify header information - headers already sent

CakePHP FAQ: Help, I'm getting a CakePHP error message like "Cannot modify header information - headers already sent"; what's going on? (Oh, and I may have just added some "redirect" functionality to my application.)

cake bake MAMP MySQL socket connection refused error

CakePHP MAMP MySQL FAQ: I'm using the "cake bake" command in a CakePHP application I'm developing using MAMP, and I get a MySQL socket connection error, specifically:

Free Flash charts and graphs (PHP charts)

Free PHP Flash charts FAQ: What do you know about Flash charts (Flash charts and graphs tools that can be used in PHP applications), especially free Flash charting and graphing tools (or interactive charts and graphs)?

As I keep digging into free PHP charts and graphs tools, I've found that several of these tools special in "Flash charts", typically interactive Flash charts. Here's a quick review of what I've learned about these Flash charts.

Free PHP Flash charts and graphs tools (Open Source)

Open Flash Chart Project

A CakePHP cheat sheet (CakePHP reference page)

Summary: This is a CakePHP cheat sheet. (Note: This reference was initially created in 2011, and may be slightly out of date.)

As I embark on another CakePHP project after a long hiatus, I'm trying to cram CakePHP back into my head. As part of this effort, I'm creating this large CakePHP cheat sheet (reference page), which I hope will be helpful to the CakePHP community. It is based on both the CakePHP cheat sheet on their Trac website and the CakePHP Cookbook (see the links below).

A PHP preg_match integer regex pattern matching example

PHP integer FAQ: Can you demonstrate a regular expression pattern to match an integer?

Interestingly, while reading a book titled Advanced PHP Programming, the author mentions that the PHP is_int function doesn't work exactly the way you expect it to. It just tests to see whether a given variable is typed as an integer or something else, so if you give it a string like "123", it will return false. This is a bad thing when you're trying to test web form data, for example.

PHP write stderr - Write to STDERR in a PHP script

PHP STDERR FAQ - How do I write to STDERR in a PHP script, specifically a PHP command line script?

I've written a lot of my command line scripts in PHP lately, and I just ran across this problem in my own script, how to write to STDERR in PHP. Fortunately the solution is easy, just use the PHP fwrite function like this:

fwrite(STDERR, “hello, world\n”);

Or, in a more real-world example, here's how I'm writing MySQL error messages to STDERR in PHP:

A PHP last character function

PHP string FAQ: Can you share some source code for a PHP last character function (string function)?

Sure, I just developed a PHP last character function for an app I'm working on, and here's the source code for that function, aptly named last_char:

# a php last character function
function last_char($str)
{
  $len = strlen($str);
  return char_at($str, $len-1);
}

As you can tell from the code, it returns the last character from a PHP string.

Syndicate content