8 Common Mistakes in PHP Programming

PHP graphic

8 Common Mistakes in PHP programming

PHP has always been the main language used by most programmers. However, with time, PHP has evolved into something really sophisticated. Hence, an increasing number of mistakes makes the work frustrating. There are so many frameworks, subtleties, nuances that in the very end, even an experienced developer wastes plenty of time in debugging.

Students who study programming know what we are talking about. However, for students, there is always a solution available: PHP homework help provided by experienced developers from AssignmentCore, for example. However, if you want to do all your programming home assignments, including PHP ones, on your own, we have some tips for you.

We have collected the most typical mistakes in PHP, even some specialists do them. It happens sometimes due to ignorance, lack of knowledge or simply because people believe that it will be fine this way, too. We hope that it will help you to avoid these errors from the very start and, hence, to avoid a lot of additional work.

References Are an Evil if You Leave Them after Foreach Loops without Arranging Properly

No, we don’t deny that array references are bad. They can be very useful indeed, but only if you are willing to operate each separate element in an array.

However, you shall be very attentive when doing so. If you make something wrong, you might get a lot of unexpected results. Also, don’t overdo them. If you see that you can perfectly manage it without references, don’t use them.

Understand the isset () Behavior Correctly

Here, to avoid long texts, we would draw your attention on one crucial thing: isset () returns false if the item isn’t existent, but moreover, isset () returns false if the item is set to zero.

Reference vs. Value Returning Are Different Things

Some people still confuse terms by value and reference returning. However, it is not the only problem. Many programmers don’t pay attention to one detail: if a programmer doesn’t explicitly indicate that the value shall be returned by reference, PHP will do it on default, return it by value.

It is though not always so clear on PHP if the developer is dealing with a value or a reference. That’s why it is recommended to verify your guesses with the API documentation. There, everything is indicated absolutely clearly.

Don’t Perform Queries in a Loop

Queries performing in a loop is an error that many programmers do and then, they are surprised that their PHP isn’t functioning. However, imagine for a while if each iteration results in one separate query to a database. There will be plenty of such queries! And this is a threat to your system.

Inefficiencies Are Your Enemies

Be efficient. For example, fetch many records at a time instead of sending a separate query for every record. If you send a query for every single record, you will get a problem called “out of memory”.

Never Ignore Issues with Unicode

There is one detail you should know to understand why this issue shall never be ignored. PHP 6 core was supposed to be Unicode-aware, though it has never been done. That’s why to write code that is able to handle both ASCII strings and non-ASCII strings. Otherwise, you will be getting constant heisenbugs.

Don’t Assume That $_POST Always Contains Post Code

Yep, many developers assume that $_POST array has post data on default. That’s why you often can find these arrays empty. To make PHP load your post payload, indicate everything clearly. Also, this array is frequently applied to extract & transform data when you use it in PHP frameworks and custom scripts.

Don’t Ignore Coding Standards

You might be surprised but we have to include this advice. Many developers believe that they know everything better and disregard coding standards completely. It, in turn, brings plenty of problems with their projects.

The mentioned standards were created by the leading developers, the maintainers of such leading products as Drupal, Joomla, and similar. Ignoring them is at least unwise.They are not a one-day practice and have been created to make the work of a developer easier and more accurate. 

Final Thoughts

As you can see, the mentioned common mistakes are neither complex nor complicated. All you need to avoid them is to be attentive to and responsible for your job. And if you have doubts, ask a specialist: a reliable programming services provider.

There are many of them online, so, make sure it complies with all the standard requirements. In addition, check if you like the policy of the company, the communication of customer support, read reviews online if there are any. Don’t forget to ask in advance whether you can get any clarification after the job is submitted and something is unclear. Only after that, you can make a wise decision.



Best Rated Phone Games

Undoubtedly, we are living in a mobile era and there are no signs at all that this trend is slowing down. We have come to rely on our mobile devices, especially our smartphones for so many things that many would turn around on a night out and go back home if they had forgotten to pick up their mobile.

You only have to see what is closest to people in a pub or restaurant or watch people walking down the street to see which is the most important piece of kit about – mobile use is here to stay!

Convenience is the Name of the Game

Ever since technology advanced and the internet became more reliable and available mobile use has become so essential to many people that to have a phone stolen or to lose one is viewed as a minor disaster. Today, we shop and pay for goods and services, keep healthy, find love, pay for vacations, tickets to concerts and the movies, do the weekly shop and source our entertainment.

The savvy industries were those that saw the potential of the mobile market in the early days and optimised their services to that market with the gambling industry being possibly the savviest of them all.

The gambling industry has always pioneered new ideas and embraced new technology resulting in mobile games that have exceptional graphics, seamless game play and offer all the casino action anyone could want from anywhere and at any time.

Using your Phone to Pay for Games

Indeed, having an online casino games via a smartphone is the preferred method of many players, convenient and as exciting as any computer game, mobile play is second to none.

However, there will always be that element that would steal personal details including banking details which can put people off funding an online casino site and if that is the case for you then you might be interested to know that you can pay for your games using your smartphone – no need to give any banking details to your site which means that any hackers cannot get any banking details!

What is Payforit?

Ok, Payforit deposits explained is quick and simple to follow – it’s a safe, secure and seamless way to fund your online casino account and get the games to go.

Supported by all the main UK phone carriers Payforit is the common framework for UK mobile carriers’ phone billing services where the cost of your games is either deducted from your pay as you go balance or added onto your monthly phone bill.

Some of the mobile service providers that support Payforit includes:

  • Virgin
  • Vodaphone
  • O2
  • EE
  • Three


Simply choose the Pay by Phone or Pay by Mobile option when you want to make a deposit on the banking page of your casino and follow the simple instructions to set this option up – the name might vary but essentially, it’s the same method.

  • Choose how much you wish to deposit (there is a £30 daily limit on this method)
  • Enter Your Phone Number (a onetime process)
  • You will then be sent a confirmation code by SMS – enter it when prompted by the casino
  • You will then get a confirmation when your deposit is successful

And there you have it, you are good to go – stress free and able to enjoy your casino games whenever you choose.


Mobile vs Desktop vs Tablet online gaming – Which comes out on top?

Which platform is more popular when it comes online gambling? This article examines real data behind this question with statistics from UK online gaming website – EgyptSlots.com. Data from May-June 2018.



The winner is clear, Mobile is by far the most popular platform to gambling on with 66% of all website visits.  In second place is Desktop with 28% share and Tablet is bringing up the rear in 3rd on 6%.


What is perhaps most surprising however is that the most popular mobile device operating system is Android with 63% of mobile visits, with almost double the number of visitors compared to Apple at 35%


So why do player prefer mobile?


There are a number of reasons behind this:


  1. Mobile is always available 24/7 in almost any location

  2. Mobiles are now powerful enough to play graphically rich games

  3. Wifi / 4G is everywhere so players are always connected.

  4. Mobiles are instant, there is no boot up time like with laptops


So why do players prefer Android?


  1. Price. Android phones are generally cheaper than the equivalent Apple models.

  2. Play Store is now Open to Gambling Apps. Until mid 2017, the Google Play store was closed to gambling apps, but the opening up of this channel has exposure many UK slot sites to a new audience of mobile players.

About the source: EgyptSlots.com.  Egypt Slots have kindly provided the data for this article and we would like to thank them for the contribution. Egypt Slots is a relatively new website launched in May 2018, it leads with its main offer of 10 Free Spins on Cleopatra – https://www.egyptslots.com/No Deposit Required.  The website is extremely mobile friendly and fast to load and responsive across all major devices.

With regards to mobile slot games, they have a large number of suitable games including Cleopatra, Crown of Egypt, Starburst and Rainbow Riches.


What else can we learn from this source?


  • The most popular screen resolution is 340 x 640.

  • The most popular single device brand is still Apple Iphone as the Android market is incredibly fragmented across Samsung, Motorola, Sony and others.

  • On a lighter note, its also interesting to know that 1% of visitors still use a old fashioned mobile mousewheel to visit websites in May 2018.




The Step By Step Guide to Trading CryptoCurrencies

If you have been paying attention over the past year you will have noticed how much emphasis has been placed on cryptocurrency trading.

Everyone is talking about it. News channels are running endless broadcasts. Well known investors have all chimed in on the future of the digital assets.

This all leaves a really important question. How does one actually get involved in trading cryptocurrency. Which services do you use and what coins do you consider buying. How much should you invest and what strategy will you use?

In this short post, we will attempt to answer all of these questions and give you a comprehensive overview of the best way to trade crypto.

Setting Yourself Up

Before you can begin trading crypto, you need to have a broker or exchange account in order to buy / trade the coins. Which one you decide to use depends on what sort of trading strategy you want to embark on.

If you are the more of the “Buy and Hold” type of trader, then you are better served to open an account with a cryptocurrency exchange such as Coinbase, buy the coins and store them in the wallet.

However, if you are interested in trading your coins on a daily / weekly basis then you are better served opening a brokerage account with a CFD broker. We are going to look at the analysis assuming that you are going with this option.

There are a number of CFD brokers that you can use but it is perhaps the wisest to make use of a regulated broker. This way you are protected in the case of any liquidity shortages at the brokerage level.

One of the most renowned brokers that you can use is IQ Option. They are based in Europe and are fully regulated. There are numerous benefits over similar platforms that we will not go into here. You can always read about IQ Option in online reviews.

Which Strategy

Before you can move onto which coins you would like to trade, you have to decide on the type of strategy that you would like to trade with. This is because many of the coins that you would consider are too small to run technical analysis with.

These small cap alt coins would be better served if they were traded as some more fundamental weekly based strategy.

For those who do not know, technical analysis is the practice of trading an asset based on information that is provided in the price of that asset itself. There is no fundamental information that is included in this analysis.

Fundamental information is based on the underlying technology, supply / demand and team dynamic that drives the value of the coin.

It is up to you to decide which strategy is better suited toy your investing style and there are a number of cryptocurreny options.

Which Coins to Buy

This is of course the most important part and it comes down to which coins you should actively consider investing in. This is of course no small feat as there are indeed thousands of coins that are available.

If you are going to be trading with technical analysis, then you are better served trading a coin that has a high market cap and is highly liquid. This is because you want to try and eliminate any idiosyncratic or non systematic risk form your trading.

Currently, the two coins with the largest market cap on the market are Bitcoin and Ethereum. These will have the volume that is required in order to trade and are most likely to conform to the typical technical analysis indicators.

If, on the other hand, you are more interested in investing based on project fundamentals, team members and technology protocols, then there are range of other alt coins that you can consider investing in.

What is most important though is knowing exactly what you are investing in as it is based on the fundamentals and not the price. You need to read the whitepapers, research the team and compile your analysis.

Only then can you confidently say that you have picked out a great project. It is also really important to make sure that you are spreading your risk out across a wide range of project types. For example, you should have a coin that is focused on privacy, a coin that is focused on payments and another that is focused on programming.

How Much Should You Invest?

This is also another really important factor to consider. How much you are willing to invest will be the driving factor in your returns / losses.

It probably goes without saying that you should never invest more than you are willing to lose. That goes for investment in traditional asset classes as well as crypto. You should only take a small proportion of your savings as your cryptocurrency investing pot.

Then, once you know exactly how much you are going to “play” with, you have to have a strong strategy of how you will realise your gains and cut your losses.

This is particularly relevant in the case of technical analysis day trading. Here, you are often trading on leverage and if the markets move against you, it is completely possible that could lose way more than you initially invested.

Hence, it is really important that you place tight stop losses around your positions. These are orders that are placed automatically when your position is above or below a certain level. They are used by all day traders.


As we have shown, investing in cryptocurrency is no small feat. There are number of things that you have to consider before you start. It is important for you to make sure that your motivations and strategies are well thought out.

With that being said, it can also be one of the most rewarding. You are participating in the new economy and you are investing in assets that are set to revolutionise the financial world.

Just make sure that you are investing responsibly and not taking undue risks. Always limit your exposure and know when to exit a bad trade.

Good Luck!


How 3D can help your PowerPoint

Enhance your presentation by going beyond the template

PowerPoint templates are one of the quickest ways in which a professional can relate information to a large group of people quickly and visually. As such free templates for PowerPoint have populated the internet, making for rather repetitive selections. Those wishing to break away from the cliché and the mundane must therefore have other elements within their template to engage the viewer. And while adding the transitions and the animations available in the program may give a low level of engagement with the PowerPoint, 3D elements can dynamically change the level of professionalism in your template. Here is how.

Background images

The background pictures which are generally provided for PowerPoint images is rather restrictive. Gradients and clip art dominate the software. However, to bring a new level of dynamics to your template, use a 3D model and render out an interior space. Since you can adjust the opacity and the saturation of the picture, you can still keep the color scheme of the presentation, but now your background will have depth.

In addition to having a static 3D image as your background, you can also use a 3D render to adjust your template for more personal use. For example, if you open PowerPoint and use the standard Gallery settings, it is pretty cookie cutter in nature. However, if you were to change the background image from the standard wood floor white look to a museum or art gallery render, the feel would look different. The same is true for office spaces. If you want your viewers to associate your presentation with your office, take a HD picture of your office and use it as the background.

3D Models

PowerPoint templates tend to be rather flat in their design. Sure, you can get some drop shadow and some beveling options, but adding 3D elements is one of the best ways in which to make a certain part of the presentation POP. The good thing about 3D models is that there are a ton of free and inexpensive options available. Places like CGTrader have models in a range of categories from the anime warrior to the suit and tie politician. Don’t need a character? Use a prop. Chairs, furnishings, homes, pencils, cars, you name it are all things which can drive the focal point and the message you are trying to convey.

When picking your 3D models, ensure that you have the software to render a PNG image of the character. This will provide you with a clear background around the character while still giving the character the depth, light, and shadows needed. Should you not have the software you could either (a) download the trial version or (b) contact the artist and ask that person to render out the character in PNG format.

Transitions for animations

Should you really wish to bring up the level of your PowerPoint template, you can do some animations using 3D renders and motion paths. This is a bit of an advanced process, but there are a great many tutorials on how you can add such transitions and animations to your scene. Doing cross reveals, sliders on a motion path, and revolves are a great way in which you can couple your 3D, your static text, and animations to bring your presentation to a new level.

Keep in mind that you can also add YouTube videos into your presentation as well. Should you wish, for example, to show the entire space of an architectural conceptualization to a potential client in your PowerPoint presentation, you would need to have a 3D model of the building and then render out the 360 of the space. In order to present the video without having to open several programs, link the video via embedded link into your presentation. When designing your template, be cautious of the number of videos you embed as this could potentially cause slags and freezing of the presentation depending on the machine and version of the software that you own.

Note: Animations should be kept to a reasonable level as adding too many moving parts to your PowerPoint template could be distracting to the viewer, taking away from the information you are trying to relate.

Go beyond the template

Whether you choose the subtle 3D or the more dynamic options, using 3D in your PowerPoint templates is sure to add dynamics and something unique to the presentation. Remember, people are more prone to remember visual data. Present your viewers with something that sets your presentation apart from the other cliché templates and presentations which are available. It does not have to be cinematic to be impactful, it just need to be impactful to be remembered. How you do that is up to your imagination.


Github webhook PHP script for automated git pull on linux server

If you have a php website repository on Github and want to immediately deploy it to your server directory whenever you push to that repository from anywhere, then you should consider setting up a webhook in Github that will be triggered whenever anything is pushed to the repository. The webhook is just a php script that will be executed on your server and it will perform a git pull on the repository cloned on your server. You can clone this repository in a webroot so that whenever you push, your changes are immediately reflected on the server.
Following is a php script I use to automate this task. Several things to note before using this script :

  • Script assumes that your Github repository is cloned on your server
  • You may need to install sendmail on linux server since the script sends an email report to you whenever a hook is triggered
  • You need to give read/write access to the server directory where git pull will take place to the user your apache (or any other) server is running as (usually ‘daemon’ on ubuntu server or ‘www’)
  • You need to Setup a ‘Secret’ which is like a passphrase by going to Github–>Your Repo–>Settings–>Webhook. You will also need to configure this secret in the php script or as an environment variable on your server. This is used to authenticate and validate requests from Github and deny any other malicious attempts at triggering your webhook endpoint script

Without further ado, here is the php script code and the corresponding configuration file. Make sure to place the configuration file outside of your webroot so that it is not accessible from outside.


Github webhook PHP script :

 * PHP endpoint for github webhook
 * original: https://help.github.com/articles/post-receive-hooks
 * modified by dynamicguru.com

 // Configuration :
$error_email = "youremail@domain.com"; // The email address to send report to in case an error occurs while executing this script
$php_script_information = "Email triggered by : ".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
$script_email_name = "Github webhook pull script";  // The name of sender used in email reports that will be sent

function run() {
    global $php_script_information;
    global $script_email_name;    
    // Configuration :
    $secret = "SECRET_PASSPHRASE";  // The secret set in github->repo->Settings->Webhooks. You should ideally read this from $_ENV (set it using 'export' command on a linux machine)
    $commandsToRun = 'cd /path/to/server/repository; git pull';
    $config_filename = '/path/to/config.json';  // path to the configuration file, recommended to place it outside your website root (htdocs/www etc)
    if (!file_exists($config_filename)) {
        throw new Exception("Could not find ".$config_filename);    // raise an Exception if configuration file is not found

    $config = json_decode(file_get_contents($config_filename), true);   // parse the json configuration

    $postBody = $_POST['payload'];  // the payload sent by github
    $payload = json_decode($postBody);  // decode the payload sent by github, see https://developer.github.com/webhooks/#payloads
    $headerSignature = $_SERVER['HTTP_X_HUB_SIGNATURE'];    // the signature/hash of request sent by github
    $signature = 'sha1=' . hash_hmac('sha1', file_get_contents('php://input'), $secret);    // compute the signature/hash of request

    if (isset($config['email'])) {  // if an email address is set in config file, we'll send the report to that address
        $headers = 'From: '.$script_email_name."<".$config['email']['from'].">\r\n";
        $headers .= 'CC: ' . $payload->pusher->email . "\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";  // HTML email

    if (hash_equals($signature, $headerSignature)) {    // validate if this is a legit request from Github
        foreach ($config['endpoints'] as $endpoint) {
            if ($payload->repository->url == 'https://github.com/' . $endpoint['repo']
                && $payload->ref == 'refs/heads/' . $endpoint['branch']) {  // check if the push came from the right repository and branch
                // execute pull script, and record its output
                passthru($commandsToRun); // the commands to run (navigate to your directory, pull from git etc)
                $output = ob_get_contents();    // get output of commands executed
                if (isset($config['email'])) { // prepare and send the notification email
                    // build the email body, you can add more details to this by referring to the json payload that is sent by github (https://developer.github.com/webhooks/#payloads)
                    $body = 'Request by Github from IP : '.$_SERVER['REMOTE_ADDR']
                    .'<p>User <a href="https://github.com/'. $payload->pusher->name .'">@' . $payload->pusher->name . '</a>'
                    . ' has pushed to ' . $payload->repository->url
                    . ' and consequently, ' . $endpoint['action']
                    . '.</p>';
                    $body .= '<p>Here\'s a brief list of changes:</p>';
                    $body .= '<ul>';
                    foreach ($payload->commits as $commit) {    // add each commit information
                        $body .= '<li>'.$commit->message.'<br />';
                        $body .= '<small style="color:#777"> Added: <b>'.count($commit->added)
                            .'</b> &nbsp; Modified: <b>'.count($commit->modified)
                            .'</b> &nbsp; Removed: <b>'.count($commit->removed)
                            .'</b> &nbsp; <a href="' . $commit->url
                            . '">...</a></small></li>';
                    $body .= '</ul>';
                    $body .= '<p>Pull script output : </p>';
                    $body .= $output. ' ';
                    $body .= $php_script_information;
                    mail($config['email']['to'], $endpoint['action'], $body, $headers); // send out the email
                return true;
    } else {
        throw new Exception("This does not appear to be a valid request from Github.\nComputed signature was : ".$signature."\n  Github sent : ".$headerSignature." ");

try {
    if (!isset($_POST['payload'])) {
        echo "I do nothing when loaded directly :)";
    } else {
} catch ( Exception $e ) {
    $msg = $e->getMessage();
    mail($error_email,  // the address to send email to
         'Error occured while executing Github webhook endpoint',   // email subject
         $msg."\r\n".$php_script_information,   // the email body
         "From: ".$script_email_name."<script@yourdomain.com>\r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset=ISO-8859-1\r\n"    // headers


Configuration json file :

    "email": {
        "from": "script@yourdomain.com",
        "to": "you@yourdomain.com"
    "endpoints": [
            "repo": "github-username/repository-name",
            "branch": "master",
            "action": "Something changed on the server"


For more information, see https://developer.github.com/webhooks/


Do more with the browser’s in-built JavaScript console

Most would be familiar with the god-send console.log() used for debugging web applications.
Many modern browsers also implement several other handy console functions for when you need to do a little extra with the console. These functions are :

  • console.info()
  • console.warn()
  • console.error()
  • console.debug()

Here is how they look in Chrome’s console :

The different flavors of console logging

The different flavors of console logging

Common use-cases for these include helpful messages in development code or libraries and anything else you can think of.

Chrome’s Developer Tools also supports a nifty console.memory object which can help debug performance bottlenecks in your front-end applications.

2020 All rights reserved | Powered by WordPress
Back to top
Theme by dynamicguru.com