Zend Anwar

Full stack web developer

Category: PHP Basic

PHP Basic

How to Increase PHP memory limit

PHP memory limit sometimes makes it problem to upload. please check way to increase your memory limit. Way 1:  Modify php.ini Search “memory_limit” in your php.ini, and change the value of it. If no “memory_limit” found, add the following line at the end of php.ini memory_limit = 2568M ; Save file. And restart Apache. Way […]

Read More

Revolution of PHP 7: Usage of Return Types and Removal of Artifacts

28 January 2015 Boston: As the date for PHP 7’s release is approaching rapidly, the group is working really hard to fix certain issues by removing the artifacts and adding some features. There are several RFCs on which we can discuss and study a lot more. But here, we are just concentrating on the three main […]

Read More

Memcache vs Memcached

Memcache module provides handy procedural and object oriented interface to memcached, highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications. The Memcache module also provides a session handler (memcache). Memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up […]

Read More

How to Transform a String from Multi-Line to Single-Line in PHP?

It is very simple. Just add below code. echo str_replace(array(“\r”,”\n”),””, $str);

Read More

session_start(): Cannot send session cache limiter

It has very simple solution <?php ob_start(); session_start(); ?> Above session write before head section . Like <?php ob_start(); session_start(); ?> <!DOCTYPE html> // html code </html>      

Read More

How to get random value in an array ?

It is very simple. PHP random array function : array_rand() http://php.net/manual/en/function.array-rand.php $ran = array(1,2,3,4); $randomValue = array_rand($ran, 1);

Read More

How do I turn off PHP Notices?

Very simple <?php // Turn off all error reporting error_reporting(0); ?> Other interesting options for that function: <?php // Report simple running errors error_reporting(E_ERROR | E_WARNING | E_PARSE); // Reporting E_NOTICE can be good too (to report uninitialized // variables or catch variable name misspellings …) error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // Report […]

Read More

TCPDF Fatal error: Allowed memory size of 134217728 bytes exhausted

This is only memory limit problem. you can increase ini_set() function. Hope so it will work.

Read More

Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes)

This is memory limit problem. You can solve your problem several way. Answer 1 :  ini_set(‘memory_limit’, ‘-1’); // it mean memory unlimited Answer 2 :  If you have access to your PHP.ini file, change the line in PHP.ini try with memory_limit = 64M ; Maximum amount of memory a script may consume (64MB) If you […]

Read More

How to rename list of images in php

<?php $directory = “folder_name/”;       // Folder name of  images //get all image files with a .jpg extension. $images = glob($directory . “*.jpg”); $i= 1; foreach ($images as $fileinfo) { $fromImg = “D:/xampp/htdocs/imagesize/”.$fileinfo; // Read  all images of you directroy $imageName = “gallery”.$i.”.jpg”;  // Rename your own way $toImg = “D:/xampp/htdocs/imagesize/rename/”.$imageName; //Rename images location copy($fromImg,$toImg); $i++; […]

Read More