Categories
linux Microsoft

What are .deb, .rpm and .msi?


Files such as .deb and .rpm are more akin to a .zip file. They’re a directory tree of files and sub-directories that contain files related to a particular application and/or library of files.

Distros

The .deb files are meant for distributions of Linux that derive from Debian (Ubuntu, Linux Mint, etc.). The .rpm files are used primarily by distributions that derive from Redhat based distros (Fedora, CentOS, RHEL) as well as by the openSuSE distro.

What’s special about them?

These files have one other special trait that sets them apart from .zip files, in that they can include a specification that contains rules that tell the package manager software running on a system that’s installing one of these files to do additional tasks. These tasks would include things such as:

  • creating user accounts on the system
  • creating/modifying configuration files that aren’t actually contained in the .deb or .rpm file
  • set ownership/permissions on the files after installation
  • run commands as root on the system that’s installing the package
  • dependencies, both formats can include names or packages and/or service names that they require to be present on a system, prior to installation.

What about .msi files?

.msi files are similar to .deb & .rpm files but likely even more sophisticated. The .msi files are utilized by the Windows Installer and offer additional features such as:

  • GUI Framework
  • generation of uninstall sequences
  • A framework within itself – for use by 3rd party installers
  • Rollbacks
  • Advertisement
  • User Interface
  • etc.

I’d suggest taking a look at the various Wikipedia pages on these subjects if you want a more in-depth explanation.

References

'Coz sharing is caring
Categories
PHP

PHP isset() vs empty() vs is_null()

PHP has different functions which can be used to test the value of a variable. Three useful functions for this are isset(), empty() and is_null(). All these function return a boolean value. If these functions are not used in correct way they can cause unexpected results.

isset() and empty() are often viewed as functions that are opposite, however this is not always true. In this post I will explain the differences between these functions.

isset()

isset — Determine if a variable is set and is not NULL

In other words, it returns true only when the variable is not null.

empty()

empty — Determine whether a variable is empty

In other words, it will return true if the variable is an empty string, false, array(), NULL, “0?, 0, and an unset variable.

is_null()

is_null — Finds whether a variable is NULL

In other words, it returns true only when the variable is null. is_null() is opposite of isset(), except for one difference that isset() can be applied to unknown variables, but is_null() only to declared variables.

The table below is an easy reference for what these functions will return for different values. The blank spaces means the function returns bool(false).
Value of variable ($var) isset($var) empty($var) is_null($var)
“” (an empty string) bool(true) bool(true)
” ” (space) bool(true)
FALSE bool(true) bool(true)
TRUE bool(true)
array() (an empty array) bool(true) bool(true)
NULL bool(true) bool(true)
“0? (0 as a string) bool(true) bool(true)
0 (0 as an integer) bool(true) bool(true)
0.0 (0 as a float) bool(true) bool(true)
var $var; (a variable declared, but without a value) bool(true) bool(true)
NULL byte (“\ 0?) bool(true)
I have tested the above values in following environments:

  • Wampserver 2.1, Apache 2.2.21, PHP 5.3.8
  • Wampserver 2.1, Apache 2.2.17, PHP 5.3.5
  • Wampserver 2.1, Apache 2.2.17, PHP 5.2.11

You can use the code below to get the above table.

<?php
echo '<table border="1">';
echo '<tr><th>Value of variable ($var)</th><th>isset($var)</th><th>empty($var)</th><th>is_null($var)</th></tr>';
$var = '';
echo '<tr><td>"" (an empty string)</td><td>';
var_dump(isset($var));
echo '</td><td>';
var_dump(empty($var));
echo '</td><td>';
var_dump(is_null($var));
echo '</td></tr>';

$var = ' ';
echo '<tr><td>" " (space)</td><td>';
var_dump(isset($var));
echo '</td><td>';
var_dump(empty($var));
echo '</td><td>';
var_dump(is_null($var));
echo '</td></tr>';

$var = FALSE;
echo '<tr><td>FALSE</td><td>';
var_dump(isset($var));
echo '</td><td>';
var_dump(empty($var));
echo '</td><td>';
var_dump(is_null($var));
echo '</td></tr>';

$var = TRUE;
echo '<tr><td>TRUE</td><td>';
var_dump(isset($var));
echo '</td><td>';
var_dump(empty($var));
echo '</td><td>';
var_dump(is_null($var));
echo '</td></tr>';

$var = array();
echo '<tr><td>array() (an empty array)</td><td>';
var_dump(isset($var));
echo '</td><td>';
var_dump(empty($var));
echo '</td><td>';
var_dump(is_null($var));
echo '</td></tr>';

$var = NULL;
echo '<tr><td>NULL</td><td>';
var_dump(isset($var));
echo '</td><td>';
var_dump(empty($var));
echo '</td><td>';
var_dump(is_null($var));
echo '</td></tr>';

$var = '0';
echo '<tr><td>"0" (0 as a string)</td><td>';
var_dump(isset($var));
echo '</td><td>';
var_dump(empty($var));
echo '</td><td>';
var_dump(is_null($var));
echo '</td></tr>';

$var = 0;
echo '<tr><td>0 (0 as an integer)</td><td>';
var_dump(isset($var));
echo '</td><td>';
var_dump(empty($var));
echo '</td><td>';
var_dump(is_null($var));
echo '</td></tr>';

$var = 0.0;
echo '<tr><td>0.0 (0 as a float)</td><td>';
var_dump(isset($var));
echo '</td><td>';
var_dump(empty($var));
echo '</td><td>';
var_dump(is_null($var));
echo '</td></tr>';

unset($var); // doing this just as a precaution, to make sure $var is actually not defined.
$var;
echo '<tr><td>var $var; (a variable declared, but without a value)</td><td>';
var_dump(isset($var));
echo '</td><td>';
var_dump(empty($var));
echo '</td><td>';
var_dump(is_null($var));
echo '</td></tr>';

$var = '\0';
echo '<tr><td>NULL byte ("\ 0")</td><td>';
var_dump(isset($var));
echo '</td><td>';
var_dump(empty($var));
echo '</td><td>';
var_dump(is_null($var));
echo '</td></tr>';

echo '</table>';
?>
'Coz sharing is caring