Saturday, November 28, 2015

Is it always necessary to use "is_array()" before a foreach?

Many times I see a code, that fails because of one simple and very common programmer mistake.
Programmers often use variabled in foreach() construction without validation before.

This mistake may leads to unstable work of your code.
It must be a "golden" rule of every PHP programmer to always use a validation of  variable before running foreach() construction.

You may do it in few ways:

1. Direct validation:
if(is_array($users))   {
    foreach($users as $user){


2. Casting (not recommended, you know why, right?):
foreach((array)$users as $user){


such way is better, but still...:
$users = (array)$users;
foreach($users as $user){


3. Your own function for handling such cases:
function actionHandelingUsers($users)
        throw new Exception('$users must be an array');

    foreach($users as $user){

Ok, but sometimes I hear a following argument: my function is always returns an array, why do I need to perform a validation?

The answer is simple: there is no always in programming - what if I decide to change yuor function output? What will be with yuor code after the function will return TRUE instead of array()? You know, right - your code will crash...

The same answer about  using of empty() instead of is_array(): empty() doesn't check if the value is array... , so you may not use it in this case.

Wednesday, November 25, 2015

New version 4.3.9 of ApPHP Hotel Site script has been released

The new version 4.3.9 of ApPHP Hotel Site script has been released is available now for
downloading. There are some bugs fixed and many new additions and improvements, including new paid template.

ApPHP Hotel Site is a powerful hotel management and online booking/reservation site script. This script is the fully functional PHP solution to manage small to medium size of hotels, holiday flats or guesthouse. Our hotel reservation system allows you to start online reservation and customer management in minutes. It has been specially designed to simplify the task of hotel booking online.

Here the main additions and improvements in the last version:
Feature: [added] possibility to define separate payment gateways for hotels
Feature: [added] added MySQLi database driver
Feature: [added] possibility to allow using separate payment gateways for each hotel
Feature: [added] possibility to show checkin/checkout info on dashboard

Feature: [improved] css changes for rtl template for lytebox
Feature: [improved] structure of the core classes
Feature: [improved] removed option All Rooms from occupancy calendar for multiple hotels
Feature: [improved] installation wizard
Feature: [improved] syntax changes in PHP code and optimizations
 Feature: [improved] security fixes in room prices and availability pages
  • Bugs fixed 
To view a Live Demo click here.

To download new version click here.

Friday, June 12, 2015

New version 4.0.1 of ApPHP MicroBlog has been released

We've released new version 4.0.1 of ApPHP MicroBlog. ApPHP MicroBlog (ApPHP MicroB) is very simple and powerful PHP blog software. This product enables you to start your own blog within minutes. You can easy add and manage your posts and posting categories. This script is perfect for web designers and developers that want to empower their site and save the time on editing web pages every time they want to add more news. The script is very flexible, it written in object-oriented style and allows web developers easy change it to suit their needs.

Download the latest version.

You may also check our templates for this script, including responsive templates from our partner

Version 4.0.1 changes (May 16, 2015):

  • New script redone with full MVC structure based on ApPHP Directy CMF
  • New added author role and privileges
  • Enh functionality of adding tags to post with xoxco component
  • Fix bugs fixed