Posts related to programming

PHP – Variables, Types and Operators

What is a variable?A variable is like a custom-made box. It can only hold one thing at a time and you

should specify the type of thing you want to put in it when it’s being made.Each variable starts with a dollar sign ($) in PHP and can hold various types of data (e.g: strings (‘Hello’), integers (5), floats (3.141592), arrays ({1,2,3})). Each variable can only hold one value in it at a time but the value can be changed later on.

Explicit Type Conversion/Type Declaration

When first declaring a variable, you can choose to tell PHP what type you want to store in it and will then convert the value you give it to match.

Implicit Type Conversion

PHP will automagically convert variables into the relevant type on its own without you needing to declare its type. It’s always best to think clearly of the type you need and tell PHP that you want that type to ensure everything works the way you intend it to.

read more