PHP Lessons 5: Loops

by
Guest-GS

Loooooops!

In this lesson, we will have a look at the foreach function in php.

First, what is a loop? I’d say something that repeats or involves a repetition can be considered a loop. In programming, you use a loop to have a bunch of codes run for a number you set. If there were no loops, you’d have to write that piece of code x times if you wanted to run it for x times, which is crazy! Read on to know the solution!

Continue Reading »

PHP Lessons Part 4: Arrays

by
Guest-GS

Ok, even some developers who already understand php a little are always confused about arrays and don’t really know how to use them. In this lessons, we will try to cover the basic uses of Arrays in PHP.

When you declare a variable, it can only hold one value. Like the example below:

<?php

$my_variable = "This is some text";

?>

As you can see, it can only store “This is some text”, or a single value. But what if you have to store multiple values which have some relationship between them? Let’s take an example from the previous lesson, remember our guy named John? We declared his age. Let’s say we want to add his name, location etc. We can do it like this:

$persons_age = ’16’;
$persons_name = ‘John’;
$persons_location = ‘California’;

But with the use of arrays, you can store all of that information in one variable. Like below:

<?php

$persons = array('John','16','California');

?>

 Continue Reading »

PHP Lessons Part 3: Conditional Statements

by
Guest-GS

Today we will have a look at what Conditional Statements are.

Conditional Statements allow you to perform different kinds of actions based on a given condition. It can either return true or false.

A little Non-Programming example to give you an idea of Conditional Statement Below:

Let’s consider a guy named John, is 16 years old and wants to go to a casino. Unfortunately, casinos doesn’t allow Minors.

So basicaly, the condition is:

If John is less than 18 years old, then don’t let him inside the casino, else, let him in.

Now there are two words that are always used in PHP Conditional Statement. They are “IF” and “ELSE”. Before going on, you should know we are using caps here for emphasis. When using these keywords in code, they are lowercase! PHP is case-sensitive. “IF” and “if” are different things for PHP. Use “if” in code.

Continue Reading »

Some Spams

by
Guru

Introducing the spammers messages.

Your blog is very new, I like! I would like you to update it often! I like your recent posts. You obviously have a natural ability to blog!

– By some s.o.a.b*

Good post! I plan to move into this stuff after I’m done with school, as most of it is time consuming. It’s a great post to reference back to. My blog needs more time to gain in popularity anyway

-By another s.o.a.b*

This is a great article. I’m new to blogging but still learning. Thanks for the great resource.

-By another s.o.a.b*

This is great! It really shows me where to expand my blog. I think that sometime in the future I might try to write a book to go along with my blog, but we will see…Good post with useful tips and ideas

-By another s.o.a.b*

*s.o.a.b = Son of a female dog 🙂

Checking the comments I saw 4 new comments and they were all spams. I need to activate Akismet to deal with the spammers. Do not forget to share your spam comments.

Edit by Inf: redacted the swears! 😀

Also, it seems we have new kinds of spam comments now. Those s.o.b of spammers are very crafty! They put a legit message in the body, and then, put their links as the URL field. This effectively kills the protection offered by most spam-detection plugins.

I’ll put Akismet up today, to see what it can do. Let’s hope for the best. And my greatest F.U to all the spammers out there! F.U S.O.B’s!

Why 24/7 concept fails in Mauritius

by
Inf

I should add “for now” in the title. If I consider what the newspapers are reporting, the first 24/7 festival was not that much of a success. People who work at the Central Market were idling due to a lack of customers. The hawkers seem to be quite happy though. Shops were closed by 22h due to that same lack of buyers. The only place which was very active was the Caudan Waterfront.

So, what went wrong? Nothing as such. It was a perfectly engineered festival. They had planned a concert, had the shops of Port Louis participate in the event by remaining open, and even had a few hawkers and food sellers around to help. The only problem was the people who were supposed to be there. The expected crowd was absent, for some very simple reasons. Then, what are those reasons anyway?

Continue Reading »

PHP Lessons Part 2: Operators

by
Guest-GS

Welcome to Part 2 of the PHP lessons.

In the previous lesson, we talked about how to get started with PHP, setting up a local environment to develop in PHP. We also talked about Variables and how they can be very useful when developing.

Just to refresh yourself up, the way we write a variable is like so:


$myVariable = "This is some fancy text";
echo $myVariable;
?>

Continue Reading »

PHP Lessons Part 1: Introduction to PHP and Variables

by
Guest-GS

What is php?

PHP is a powerful programming language for programmers to add interactivity to web pages, making them dynamic. What does “dynamic” mean? Simply “not static”! It may seem strange, but this is exactly what it is. Traditionally, web pages were “static”, coded in HTML. Nowadays, these pages are filled contents that change over time. Think about a blog, if you’re starting one then get managed wordpress hosting with knownhost. Aren’t new articles added from time to time? Well in the past, someone had to go edit a webpage, add code and add the article there manually. Nowadays, the article is pulled from a database, and dynamically added to a page as it is posted. That’s what PHP does: generating pages on the fly with content, with the help of HTML and other languages of course.

PHP is free (as in no cash needed, and open source – you can download and view the PHP source code) and is among the most popular programming languages used for Website Developement, to do processing.

What does PHP stands for?

PHP means: Hypertext Pre-Processor (HP, right? It’s a recursive acronym! It originally meant, Personal Home Page). It is a server side language and are executed on a server (Not on a local machine like Javascript, HTML and CSS). PHP can interact with Many databases out there such as MySql, Oracle, etc. To fully make use of PHP, a minimum knowledge of HTML is required, as well as some basic CSS if you wish to make things look nicer, but CSS is not directly required.

Continue Reading »