Skip to content

Mastering PHP and Laravel

Never stop learning!

Menu

  • Home
  • Blog Posts
  • Humor

PHP

Coerced in two different ways

$x = NULL; if (‘0xFF’ == 255) { $x = (int)’0xFF’; } This problem tests your knowledge of how type juggling, or coercion works. When a string and a number are compared with the equality operator, the string is coerced

Kenny July 10, 2018September 27, 2023 Blog Posts, Learning, PHP, Programming Read more

and, it’s not what you expected

$x = true and false; var_dump($x); This one is interesting. In PHP, you can use && or and to do a logical comparison. However, due to the Operator Precedence rules, and actually has lower precedence than =, where && has higher!

Kenny July 10, 2018September 27, 2023 Blog Posts, Learning, PHP, Programming Read more

Testing your knowledge of array_merge

$arr = array(); $arr[‘val1’] = array(1, 2); $arr[‘val2’] = 3; $arr[‘val3’] = array(4, 5); $arr2 = array(); $arr2 = array_merge($arr2, $arr[‘val1’]); var_dump($arr2); $arr2 = array_merge($arr2, $arr[‘val2’]); var_dump($arr2); $arr2 = array_merge($arr2, $arr[‘val3′]); var_dump($arr2); There’s a problem with this code. It lies

Kenny July 10, 2018September 27, 2023 Blog Posts, Learning, PHP, Programming Read more

Watch out for that Octal!

var_dump(0123 == 123); var_dump(‘0123’ == 123); var_dump(‘0123’ === 123); At first glance one might think that the leading zero on line one is simply of no value. But one would be wrong… In PHP, a leading zero in a number

Kenny July 10, 2018September 27, 2023 Blog Posts, Learning, PHP, Programming Read more

strpos gotcha!

$string1 = ‘php is fun!’; $string2 = ‘php’; if (strpos($string1,$string2)) { echo “\”” . $string1 . “\” contains \”” . $string2 . “\””; } else { echo “\”” . $string1 . “\” does not contain \”” . $string2 . “\””;

Kenny July 10, 2018September 27, 2023 Blog Posts, Learning, PHP, Programming Read more

Post-Fix Increment Problem with Solution

Today I saw an interesting problem. At first glance I wasn’t sure what I was looking at. It took me a moment to parse it. Here is my own version of the problem: $x = 3; echo $x; echo “<br

Kenny July 10, 2018September 27, 2023 Blog Posts, Learning, PHP, Programming Read more

Making progress in Laravel

I’m making good progress in learning Laravel. I just wrote a service provider, and then created a Facade for it. The concepts are coming together nicely. Here are a few of the pages I used to help figure this out: https://laravel.com/docs/5.2/providers#registering-providers

Kenny March 29, 2016September 27, 2023 Blog Posts, Laravel, Learning, PHP, Programming Read more

Laracast: Laravel 5 Fundamentals

Today I’m starting the Laracast “Laravel 5 Fundamentals”. Let’s see how long it takes me to complete it…

Kenny February 11, 2016September 27, 2023 Blog Posts, Laravel, Programming Read more

Factories and base classes

Today I refactored some code, And for the first time ever I wrote a factory class. I have a class that calls a specific service on the web. I had that class directly referenced in other parts of my code.

Kenny February 23, 2015September 27, 2023 Blog Posts, PHP Read more

PHP Architect’s Zend PHP Certification Study Guide

PHP Architect’s Zend PHP Certification Study Guide

So, today I started chapter three, on arrays. I learned something new! The list() function. That may just come in handy someday. 🙂

Kenny February 21, 2015September 27, 2023 Blog Posts, PHP Read more

The Checklist Manifesto

At SunshinePHP this year, at one of the talks, the speaker mentioned a book called “The Checklist Manifesto”. I started reading it yesterday and I’m halfway through it already. It’s a good read that explains why checklists are so vital

Kenny February 16, 2015September 27, 2023 Blog Posts, Community Read more

Sunshine PHP 2015

This year’s Sunshine PHP conference is only the second I’ve attended. My first was Tek in Chicago, in 2013. Having 2 years of PHP experience behind me now has made a big difference in my understanding of the topics presented

Kenny February 10, 2015September 27, 2023 Blog Posts, Community, PHP Read more

Which way is better?

While going though some code in a plugin (not one I wrote), I came across the following snippet: if ( !isset($update_transient->checked) ) return $update_transient; else $themes = $update_transient->checked; Looking at this makes me cringe. Here’s how I would write this:

Kenny January 27, 2015September 27, 2023 Blog Posts, Community, PHP Read more

2014: A look back

So here we are on the eve of a new year. 2014 has been a good one for me. I decided to look back over my posts for the year, and discovered that I only posted 10 times in 2014! 

Kenny December 31, 2014September 27, 2023 Blog Posts, Community, PHP Read more

WordPress plugin OOP template

<?php /* Plugin Name: Plugin URI: http:// Description: Version: 1.0 Author: Kenny Ray Author URI: http:// License: GPL2 */ if (strpos($_SERVER[‘SERVER_ADDR’],’localhost’)) { error_reporting(E_ALL); ini_set(‘display_errors’, 1); } // Be sure to update this name, and make the one at the very

Kenny December 5, 2014September 27, 2023 Blog Posts, PHP Read more

Installing Laravel site: permissions

If you get this error Error in exception handler. when trying to hit the root of a new install, do these two things on OSX:   sudo chown -R _www app/storage (replace _www with your Apache server name if necessary)

Kenny October 27, 2014September 27, 2023 Blog Posts, Laravel, PHP Read more

SRP : Single Responsibility Principle

This is the clearest beginner level explanation of the Single Responsibility Principle that I’ve seen so far: http://code.tutsplus.com/tutorials/solid-part-1-the-single-responsibility-principle–net-36074

Kenny September 11, 2014September 27, 2023 Blog Posts, PHP Read more

Learn Composer

I just found a really good video tutorial on Composer:   http://knpuniversity.com/screencast/composer/composer

Kenny November 26, 2013September 27, 2023 Blog Posts, PHP Read more

How to handle login correctly in an iPhone app that connects to a web service

I am currently designing an iPhone app. It uses a web api that I’m building in PHP. The app requires users to login. What I am currently researching, and having a really hard time figuring out, is if there is

Kenny September 3, 2013September 27, 2023 Blog Posts, iPhone, Objective C, PHP Read more

PHP Sessions: Part 4

Session Locking. Some people don’t ever consider this. I have dealt with it before in another language, so I decided to do a quick search to see what it looks like in PHP. The basic idea is that only one

Kenny June 5, 2013September 27, 2023 Blog Posts, PHP Read more
  • « Previous
  • Next »

Archives

Categories

Copyright © 2025 Mastering PHP and Laravel. All rights reserved. Theme Spacious by ThemeGrill. Powered by: WordPress.