PHP Registered Hashing Algorithms

PHP Registered Hashing Algorithms and their Hashed Value Length

PHP has a many hashing functions like sha1(), hash(), md5(), etc that can be used to hash a string/number based on certain algorithms i.e. “sha1”, “sha256”, “md5”, etc. You can use hash_algos() function to check a list of registered hashing algorithms. All these function takes a string/number as an argument and output an Alpha-Numeric hashed string of certain length. hash_algos() — Return a list of registered hashing algorithms. Currently PHP supports 46 hashing algorithms. hash_algos() function returns a numerically indexed array containing the list of supported hashing algorithms. Each hashing algorithm has a specific hashed value length. PHP Hash Algorithms Name & Length S.No. Algorithm Name Length 1 md2 32 2 md4 32 3 md5 32 4 sha1 40 5 …

Read More
Generate Random String Number in PHP JavaScript Ruby Python

Generating Random String Using PHP, JavaScript, Ruby, Python

Sometime in the programming world, you may need to generate a random string for any purpose, just like to random password suggestions, random passwords for your users. Today, In this Article we will study how can we achieve that in the easiest and fastest way. Random password / Random String can be generated with fully-custom functions but when we compare that with custom function those uses pre-defined functions of that language then that will be the best and fastest. As pre-defined function’s definitions are already compiled where the fully-custom functions are not compiled. Compiler/Interpreter will compile the code (fully-custom function) before executing that. And that will take a couple of microseconds to make it executable. But when it comes with …

Read More
Coders Den

Get Mime Type of file without reading file metas

What is MIME Type? MIME stands for Multipurpose Internet Mail Extension. It is the standardized way to identify the nature and format of a document. It is defined and standardized in IETF RFC 6838. The Internet Assigned Numbers Authority (IANA) is the official body who is responsible for keeping track of all official MIME types, and you can find the most up-to-date and complete list at the Media Types page. Syntax of MIME Type type/subtype MIME type string is a combination of 2 strings that are Type & SubType separated by / symbol. There should not be any space between Type & SubType. Type is a category of multiple MIME types of common groups that are closely related to each other. SubType …

Read More

Install LAMP AWS EC Ubuntu 16.04 – PHP 7, Apache, MySQL 5.7, GD, iMagick, Curl, MemCache

What is LAMP LAMP stands for: L = Linux as the operating system platform. A = Apache as the Web server M = MySQL as the database server P = PHP as the supportive language In this tutorial, we are going to see how to setup/install LAMP server on Ubuntu 14.x. This tutorial will cover the installation of PHP 7.0, Apache 2 & MySql 5.7, GD, iMagick, Curl, MemCache, Sqlite3, etc Instance Setup Install Apache2 Web Server

Verify: Install PHP 7

Restart Apache 2 Server To reflect changes in a server you need to restart the server. To restart server run the following command in SSH terminal window.

Check Installed PHP Version After successfully restart server run …

Read More

What are traits in PHP OOPS / Laravel ?

What is Traits? Traits are a mechanism that allows you to create reusable code in languages like PHP where multiple inheritance is not supported. A Trait cannot be instantiated on its own. In layman language,  traits are simply a group of methods that you want to include within another class. A Trait is like an abstract class that cannot be instantiated by itself. The trait is created to reduce the limitations of single inheritance in PHP by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies. Example of Trait:

To use Trait within the other classes use use keyword with Trait name. i.e. user AbcClass;

Now if you create new objects …

Read More
Ubuntu iMagick

How to install iMagick for PHP 7.x in Ubuntu 14 and above

Imagick is the most famous & best PHP extension for image manipulations. You can create and modify images using the iMagick (ImageMagick) library. It’s known on other platforms due to its difficult installation process, however in Ubuntu, installing it is pretty easy thanks to the php-imagick package that installs ImageMagick and Imagick as well. If you want to install Imagick on your server in just a couple of minutes, follow these steps: Install PHP Imagick To use Imagick with PHP 7.x in your server, you can easily achieve it with the following command:

The source of the package is the original package of Imagick from pecl. The installation takes about 1-2 minutes. You just need to press ‘Y’ each …

Read More
set default php version

Set Default PHP Version in Ubuntu

You can set the default PHP version to be used on the system with the “update-alternatives” command, after setting it, check the PHP version to confirm whether desired PHP version is set as default or not.

Restart apache server

Check PHP version

Output of above command is Check PHP configuration file You can find your PHP configuration file, by running the command below.

Output of above command is Now, check the current PHP version with phpinfo. Sometime you may see phpinfo() function shows older/different PHP version and SSH command line shows newer/different PHP version. To over come with this issue you need to disable unwanted PHP version and enable desired installed PHP version. Disable PHP5 module …

Read More

Install PHP 7.x GD Library on Ubuntu 14.x

PHP 7 do not come with GD library you need to install it manually. Depending on your current installed PHP version you may install GD library on Ubuntu. Install PHP 7.x (7.0, 7.1, 7.2, etc) GD library

Restart apache server

Now check phpinfo whether GD library is installed or not? Use bellow function in any file and open that file on browser.

Do browser search for GD. If you see “GD Support” is enabled. Then your GD library is successfully installed. Now you may use GD library for image manipulations.

Read More
mbstring extension missing php7 phpmyadmin

Install mbstring extension PHP 7 on ubuntu

Multibyte String (mbstring) extension in deprecated in PHP 7 and above. If you are using PHP 7 & above and you want to access phpMyAdmin. You may face an error i.e. “The mbstring extension is missing. Please check your PHP configuration.” Install mbstring extension PHP 7.x on ubuntu

Restart apache server

Cheers! mbstring extension is installed and auto configured now you can access phpMyAdmin.

Read More
Could not instantiate mail function - PHPMailer

Could not instantiate mail function – PHPMailer

If you are using PHPMailer just to send mail and you are not using isSMTP() then PHPMailer uses PHP’s mail() function. If your server does not support PHP mail() function. Then PHPMailer will throw Fetal Error. And this error is well defined on PHPMailer Github Documentation. PHPMailer without isSMTP() not working? This means that your PHP installation is not configured to call the mail() function correctly (e.g. sendmail_path is not set correctly in your php.ini), or you have no local mail server installed and configured. To fix this you need to do one or more of these things: Install a local mail server (e.g. postfix). Ensure that your sendmail_path points at the sendmail binary (usually /usr/sbin/sendmail) in your php.ini. Note …

Read More