Zend Anwar

Full stack web developer

Category: PHP Basic

PHP Basic

How to copy a file from one directory to another using PHP?

This should be pretty easy. You want to copy & rename images that already exist on the server while still retaining the original image. Here’s the original image location: images/ folder/ your_image_name.jpg This is what I want: images/ folder/ your_image_name.jpg your_image_new_name.jpg <?php $file = ‘images/folder/your_image_name.jpg’; $newfile = ‘Images/folder/your_image_new_name.jpg’; if (!copy($file, $newfile)) { echo “failed to […]

Read More

Deprecated: Function set_magic_quotes_runtime()

Open the “include/config.php” find: set_magic_quotes_runtime(0); replace: ini_set(“magic_quotes_runtime”, 0); Hope it will work.

Read More

Error Reporting Directives in php.ini

Error Reporting Directives in php.ini To diagnose bugs in your code, you should enable the directive that allows error messages to be written to the browser. This is on by default. display_errors = On You can also set the level of error reporting. For working through this book, you should set this to the following: […]

Read More

New Functions in php5

New Functions in php5 PHP 5 there are some new functions. Which are given below: Arrays: array_combine() – Creates an array by using one array for keys and another for its values array_diff_uassoc() – Computes the difference of arrays with additional index check which is performed by a user supplied callback function array_udiff() – Computes […]

Read More

Website Development by PHP Basics,HTML,CSS,Javascript & Joomla 2.5

In this PHP course, you will learn Basic level PHP programming and how to execute scripts on your server. You will also learn about MySQL, HTML, CSS, and JavaScript. Advanced level CSS, Database & Relation of Database will also be discussed in the sessions. After completing the training, participants are expected to develop projects using […]

Read More

Function ereg_replace() is deprecated

Function ereg_replace() is deprecated : Example : print $input.”<hr>”.ereg_replace(‘/&/’, ‘:::’, $input); Replace print $input.”<hr>”.preg_replace(‘/&/’, ‘:::’, $input); Another  example : $anwar = ereg_replace(‘[^A-Za-z0-9_]’, ”, $ anwar ); Replace to $ anwar = preg_replace(‘/[^A-Za-z0-9_]/’, ”, $ anwar );

Read More

How to minus in array php code

How to minus in array php code $A = array(5,10,10); $B = array(1,1,1); $a=array(); for($i=0; $i<=2; $i++){ $a[$i]= $A[$i]- $B[$i]; echo”<br>”.$a[$i]; } Output: 4 9 9

Read More

Regular Expression Basic Tutorial

Characters Character Description Example Any character except [\^$.|?*+() All characters except the listed special characters match a single instance of themselves. { and } are literal characters, unless they’re part of a valid regular expression token (e.g. the {n} quantifier). a matches a \ (backslash) followed by any of [\^$.|?*+(){} A backslash escapes special characters […]

Read More

Regular Expressions Examples

Regular Expressions Examples Regular Expressions for Username Pattern : /^[a-z0-9_-]{3,16}$/ Description: The beginning of the string (^), followed by any lowercase letter (a-z), number (0-9), an underscore, or a hyphen. Next, {3,16} makes sure that are at least 3 of those characters, but no more than 16. And last, the end of the string ($). […]

Read More

How to connect php and oracle database?

oci_connect : Connect to an Oracle database. oci_connect ( string $username , string $password [, string $connection_string [, string $character_set [, int $session_mode ]]] ) To create a connection to Oracle that can be used for the lifetime of the PHP script, perform the following steps. <?php // Create connection to Oracle $conn = oci_connect(“phphol”, […]

Read More