Friday, 23 October 2015

#PHPro.: Become a Master of PHP +4: in-built Functions


There are a lot of in-built functions in PHP. A lot. And they are very useful. It's not possible to know all the in-built functions, but it's good to know enough of them. Let's start with math functions.

Pow(); This one is used to raise the power of a number. It has two parameters; the number and the power.

Pow(2,3); // This means 2 to the power of 3.

Rand(); This is used to generate a random number. It can be used without parameters, but the parameters are to set a range.
Say, I want the random number to be between 1 and 100.

Rand(1,100); Easy peasy.

Thursday, 22 October 2015

#PHPro.: Become a Master of PHP +3: Custom Functions

Yo, geeks and... humans. Let's get started with functions.
What are custom functions?
Let's say you want to create some lines of code, and you know you're going to need it again. Hell, you're probably going to want to use it like a million times. What do you do? Copy and paste it a million times? Nah, man. I'm not asgardian. You build a function, that way, all you have to do is call the function and that process will run.
Examples.

<?php 
    $num1 = 4555;
    $num2 = 99;

    function add() {

Wednesday, 21 October 2015

#PHPro.: Become a Master in PHP +2:[Control Structures]

[Control Structures]

Control structures are very powerful and important in PHP, and any other language. They are used to test conditions or repeat some code a certain number of times until a certain condition is met. Enough of chit-chat, let's jump right into it.

IF statement
This one is very simple. All it does is tests if a certain statement is true, then runs the code. Else it runs another code. E.g.

make sure you use your php tags, else, apache will just be like what the hell is this.

<?php 

$number = 6; // lets create our variable

if ($number <= 4) {

Sunday, 18 October 2015

#PHPro: Become a master in PHP

There is really no need in knowing what PHP stands for. You can google it if you want to know, you'll probably forget it.
We're here to learn how to master PHP in a month, start writing awesome code and building awesome apps.

***
FIRST STEPS
The learning process is similar for every programming language.

- Download your local server app (If you just try to run the php file, you'll look like an idiot)

- Set it up. I recommend XAMPP. Just google, you'll see it.

- Get a proper text editor. Notepad is for losers. Get something like Sublime Text, Brackets or conTEXT and you will code like a champ.

- GO AND LEARN HTML.