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 copy”; } Hope it will …

Continue Reading

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: error_reporting = E_ALL & ~ …

Continue Reading

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 the difference of arrays by …

Continue Reading

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 PHP with MySQL. Joomla! is …

Continue Reading

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 );

Continue Reading

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 to suppress their special meaning. …

Continue Reading

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 ($). Matches: an-wa3r_t5h3 Doesn’t match: dgdgd1-www_78chfdhgvsfdsaas …

Continue Reading

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”, “welcome”, “//localhost/orcl”); if (!$conn) { …

Continue Reading