SELECT c.first_name,c.last_name, o.order_total FROM customers c LEFT OUTER JOIN orders o ON c.id = o.cust_id WHERE o.order_total > 100.0 I was once asked to write a query similar to this. The goal was to select all customers who had placed
Array Sorting
I came across this problem recently: How would you sort an array of strings to their natural case-insensitive order, while maintaining their original index association? array( ‘0’ => ‘z1’, ‘1’ => ‘Z10’, ‘2’ => ‘z12’, ‘3’ => ‘Z2’, ‘4’ =>
How to enable PHP error reporting
ini_set(‘display_errors, 1); error_reporting(E_ALL); The ini_set function sets a configuration option for the duration of the script execution. When the script is done, the value returns to whatever it was set to originally in the ini file. The error_reporting function
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
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!
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
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
strpos gotcha!
$string1 = ‘php is fun!’; $string2 = ‘php’; if (strpos($string1,$string2)) { echo “\”” . $string1 . “\” contains \”” . $string2 . “\””; } else { echo “\”” . $string1 . “\” does not contain \”” . $string2 . “\””;
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
Imperative vs Declarative (Why OOP is good)
Imperative Programming focuses on how a program operates. Declarative programing focuses on what the program should accomplish without specifying how it will accomplish it. In a way, the Abstraction of Object Oriented Programming can be viewed as a more Declarative
What is Closure in JavaScript?
Closure in JavaScript is when a function is able to remember and access it’s lexical scope even when it is executed outside of it’s lexical scope. Put another way, it’s a function which can access it’s lexical scope after the
ACID
A.C.I.D. Atomicity Consistency Isolation Durability Atomicity in a database system means that a sequence of events within a transaction must all occur or nothing occurs. Because of this, the transaction cannot be observed by an outside process as “in progress”.
A PIE
There are 4 basic features that an object oriented language has. Here is an easy way to remember them: “A Pie” Abstraction Polymorphism Inheritance Encapsulation Abstraction means that only necessary information is exposed outside the class, and the details of
When To Use IEnumerable, ICollection, IList And List
Here is a great article on the differences between IEnumerable, ICollection, IList, and List, and when to use each in your C# project. When To Use IEnumerable, ICollection, IList And List
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
AngularJS on Udemy.com
I highly recommend this course. I had been struggling on and off trying to figure out AngularJS. I am proud to say that I now understand it, and can write an app from scratch. Check it out at https://www.udemy.com/learn-angularjs/learn/#/ Also, be
Laracast: Laravel 5 Fundamentals
Today I’m starting the Laracast “Laravel 5 Fundamentals”. Let’s see how long it takes me to complete it…
Laracast: Be Awesome in PHPStorm
I just finished most of the Laracast “Be Awesome in PHPStorm”. I didn’t do the last few because the topics are beyond where I am in my learning at this point. But I’ll be back for those later. Like any
Node.js on Lynda.com [complete]
A few days ago, when I started learning node.js on Lynda.com, I had heard of some of the things that were taught in that video series, but now I can say that I have worked with and understand at a
Learning Node.js
I’m currently learning node.js through Lynda.com. As part of this course, I’m also learning about unit testing, which I’m sure will come in handy soon. Once this course is done, I will probably start watching some Laracasts and learning about