All Posts Filed in ‘php

Post

StudentNetwork – A competition project

2 comments

First of all, I am sorry about the fact that I have not written on this blog since a while, since I have been quite busy with this project over the past few weeks. So, what is this about? Well, first take a look at the interface:

StudentNetwork Login Screen

StudentNetwork Login Screen

As you can see, it is a simple system that can be hosted by organisations on their local networks that can be accessible by the people existing in that particular organisation. This system consists of a live chat room, where everyone can chat with each other. This system also consists of a Question and Answers area. This place enables users to ask questions, and provide answers to each others, up vote posts, down vote posts, comment on posts, and also, the person, who asked a question can tick the best answer out of multiple answers obtained. Isn’t that amazing? Moving on, the users are able to change their personal details like their display name, email, password and of course logout of the system when their job is done. Here is what the dashboard looks like:

StudentNetwork Dashboard

StudentNetwork Dashboard

For this particular competition, the theme I chose was “Integrating education into Technology” and therefore, this is what I created. Then, I had to choose the platform, and I choose the web most importantly because the web can be easily accessible through any device which has an internet connection, and therefore, easily to target a large user base. The next decision I had to make was between PHP and Node.js for server-side. I chose PHP simply due to the fact that PHP applications are a bit easier to setup, and considering the fact that PHP7 was on the way, which made PHP look more future-proof. But, with regards to being “future-proof” I would not say Node.js is not future-proof as it is being maintained by Google. Then, I basically used HTML, CSS and Bootstrap from the UI, JavaScript with jQuery for the client side and I used MySQL as a RDBMS (relational database management system) solution.

By creating this piece of software, I placed second overall in the ESOFT Dev Challenge 2015, and was also the second in the web development category. Here are some pictures of me from there:

Me showcasing StudentNetwork

Me showcasing StudentNetwork

Us waiting for the exhibition to commence

Us waiting for the exhibition to commence

Me receiving the prize from Mr. Upul Dassanayake

Me receiving the prize from Mr. Upul Dassanayake

Group photograph of everyone present that day.

Group photograph of everyone present that day.

Me receiving the 2nd place from Mr. Dayan Rajapakshe.

Me receiving the 2nd place from Mr. Dayan Rajapakshe.

Me receiving the prize from Mr. Upul Dassanayake

Me receiving the prize from Mr. Upul Dassanayake

Post

Void return types coming in PHP 7.1!

Leave a reply

As we all know the fact that we will have the ability to declare the return types from PHP 7 onwards, there might also be situations where you may not want to return anything, and therefore, an RFC regarding void return types was initiated, which requested the implementation of the void return type for methods or functions which will indicate that there is nothing to be returned by the function or method.

You could declare the return type as void for a function or method this way:

function returnNothing(): void {
    //perform operations
}

After a vote between some PHP internal members, this idea received 37 positive votes against 7 negative, and therefore, was decided as approved for PHP 7.1 as you can see in this message here.

Post

PHP7, are you ready for it?

Leave a reply

You guys may very well be aware of the fact that PHP7 is coming by the end of this year which is something very significant to every person out there who uses PHP. May it be a freelancer, a student or a company, everyone right now is on about PHP7’s release.

1. Scalar type declarations. You guys may be aware that Scalar type declaration is a feature of PHP7, but what really is it? Well, with this feature, you can now type hint data types where-as in previous versions of PHP, it was only possible to type hint classes and arrays.

2. Return type declarations. In PHP7, not only can you type hint data types, you can also define the function or method return data type. Which is the type of data your function or method is going to return after it is done executing. For example, if your function or method returns a sum of two integers, then the return type is obviously integer.

3. Null coalesce operator. With this brand new null coalesce operator, you can make your code more shorter when using ternary operators. You may do something like $age = isset($_GET['age']) ? $_GET['age'] : null); before, but you no longer need to write that much any more! All you have to do to achieve that is to write $age = $_GET['age'] ?? null; and that is it! That does the trick for you right away.

4. Spaceship operator. This is another cool operator coming in PHP7. The symbol or the notation for this operator is <=> and it is used to compare two integers, floats or strings. If both of the values are equal, then it returns a 0. If the left value is smaller than the right value, then it returns a -1 and when the left value is greater than the right value, then it returns a positive 1. You might be wondering how the strings are determined to be greater or smaller in value, well, it is determined by the ASCII value they hold.

5. Constant arrays. With this, you can define an array which is a constant using the define() function. Until PHP 5.6, it was only possible to achieve this using the “const” keyword. The syntax is as follows:

define('PEOPLE', [
    'John',
    'Doe',
    'Jack'
]);

Sounds cool, yeah?

6. Anonymous classes. You might have heard of anonymous classes. If you haven’t, then, anonymous classes are classes which are basically not defined as normal classes. They are basically just use and dispose classes. An example would be:

$dog->setSoundAdapter(
    new class {
        public function makeSound()
        {
            echo "Woof!";
        }
    }
);

So, as you see in the above code, a class is just created as well as instantiated at the same time and passed onto a method, and as soon as it serves it purpose, it disappears from the context.

Although these are not the only features going to be implemented in PHP7, I am going to stop here. If you want to know the complete list, then you can go ahead and take a look here at the PHP’s official site.

Credits: PHP Manual for information regarding PHP7.