Posts

Showing posts with the label PHP

Function definition with returning array value - PHP

####################### PHP Code ####################### <?php function callmeforarray($a,$b) { $addition = $a + $b; $minus = $a - $b; $multiplication = $a * $b; $division = $a / $b; $modulus = $a % $b; $returnvalue['sum'] = $addition."<br/>"; $returnvalue['min'] = $minus."<br/>"; $returnvalue['mul'] = $multiplication."<br/>"; $returnvalue['div'] = $division."<br/>"; $returnvalue['mod'] = $modulus."<br/>"; return $returnvalue; } echo "<hr/>"; $result = callmeforarray(30,5); echo "Sum is : ". $result['sum']; echo "Min is : ". $result['min']; echo "mul is : ". $result['mul']; echo "div is : ". $result['div']; echo "mod is : ". $result['mo

PHP Function call - Just running the code within it

############################ PHP Code ############################ Program 01:      Normal Function just running the code within it <?php    //  Normal Function just running the code within it    //  function definition  function callme($a,$b)   {     // echo "<br/>Sum of the ".$a." and ".$b. "is = ".$a+$b;       echo "<br/>Sum of the ".$a." and ".$b. "is = ".($a+$b);       echo "<br/>Multi of the ".$a." and ".$b. "is = ".$a*$b;       echo "<br/>Min of the ".$a." and ".$b. "is = ".$a-$b;       echo "<br/>Divide of the ".$a." and ".$b. "is = ".$a/$b;       echo "<br/>Modulus of the ".$a." and ".$b. "is = ".$a%$b;     }    // function defination     // function call      callme(2,5);     // function call ?> ############################ Ou

Basic for Function on PHP

Function:        Function are a set of bloch, which are defined for calling a set of code again and again. There are two way to calling a function in PHP: Directly calling a Function. Function called by a object of a class and defined within a class.  They are Important as some of the code, we have to use different location on a site. So a good way is to define in a File i.e. "functions.php" and include it to top of the position. ############################ PHP Code ############################ Program 01:      Normal Function just running the code within it <?php //  Normal Function just running the code within it //  function definition function callme($a,$b) { // echo "<br/>Sum of the ".$a." and ".$b. "is = ".$a+$b; echo "<br/>Sum of the ".$a." and ".$b. "is = ".($a+$b); echo "<br/>Multi of the ".$a." and ".$b. "

Type of the Variable

Here we will understand, How we can know the type of the variable. As PHP automatic set the type to the variable as we defined it, But sometime it is neccessary to check the type of the variable. Suppose you have a condition, that it there is more then 10 Items in store,  you will add them all for calculation of the total payment, but when  the item is only one, there is no need to adding them, as the total cost will be cost of the item. So you can do by checking the variable type of the variable m If it is array then we will add them all, if this is only a string or Integer, and it is the final cost. Example you have an Variable $value. if it is array, we will use array function to check as follow: <?php                                $totalcost = 0;    if( is_array ($value) )               {                    foreach ( $value as $single )                       {                              $totalcost = $totalcost + $value;                    

Loop in PHP - For Loop

So we are going to understand the for loop. As you know the loop is a re-execute of a block code for the some condition to be true. For example, I will keep waking till I reached the temple. Here Temple is a condition and walk is the block of code to be executed. The structure of the for loop as follow: for  ( {initial value for the loop} ; { contion to be check } ; { initial value to be changed } ) { } #################################### PHP Code #################################### <html> <head> <title>Loop Example- for</title> </head> <body> <h3> Example 1 </h3> <?php  for ( $i = 1 ; $i < 5 ; $i++ )  { echo " <br/> The Value ot the Intiator : " . $i ; } ?> <hr/> <h3> Example 2 </h3> <?php  for ( $j = 5 ; $j > 1 ; $j-- )  { echo

Loop in PHP - while loop

There is three main loop in PHP:  while for foreach while:   while(condition) { do this } ################################### PHP Code ################################### <html> <head> <title>Loop Example</title> </head> <body> <?php /* one way of using loop: in this Program will check condition First and execute block of code within it, if the condition is true */ echo " <br/> "; $i = 0; while( $i < 10) { echo $i; echo " <br/> "; $i++;   // will increment i with 1 } echo " <hr/> "; $j = 0; do { echo $j; echo " <br/> "; // will increment j with 1 $j++; } while ( $j < 10 ) ?> </body> </html>

Logical Expression in PHP

        Today, we will talk about logical expression in PHP. Syntax of the Logical expression are same as the other Programming languages i.e. C and java. Syntax: if Condition:   if(condition)  run this if else Condition:   if(condition)  run this else run this nested if else Condition:   if(condition)  run this else if  run this else run this ############################ PHP Code ############################ <?php $a = 4; $b = 5; // if condition if( $a > $b ) // if no curly braces is used, then only next line will be executed  echo " <br/> a is  greater then b "; echo " <br/> this will not depend on the condition "; echo " <hr/> "; if( $a < $b )   echo " <br/> a is  less then b "; echo " <br/> this will not depend on the condition "; echo " <hr/> ";

What is MD5 ?

MD5 stands for 'Message Digest algorithm 5'. MD5 algorithm is used as a cryptographic hash function or a file fingerprint. Often used to encrypt password in databse, MD5 can also generate a fingerprint file to ensure that a file is the same after a transfer for example. A MD5 hash is composed of 32 hexadecimal characters. Enter a word in the MD5 encrypter form above to know the corresponding MD5 hash. What is a MD5 hash? MD5 (Message Digest algorithm, 5th version) is an algorithm which converts a given sequence of characters into another unique sequence of characters, with a fixed length, called "hash". For instance, the MD5 hash of the word "admin" is "21232f297a57a5a743894a0e4a801fc3". These hashes are mostly used to validate file integrity, to encrypt sensitive data (like passwords), and to generate unique identifiers. Is it secure? MD5 hashes are theoretically impossible to reverse directly, ie, it is not possible to retrieve the or

Type of Variable

      This program is for showing data type on PHP, There is no need to define data type on PHP. Its automatic define type to the variable as the value is assign to its. Example like: $var2  =   5;  // type will be string $var2 =  "5";  // type will be integer ######################################### PHP Code ######################################### <?php $var1  =  "The 2 Sentences"; $var2  =   5;  // type will be string $var2 =  "5";  // type will be integer echo $var1; echo "<br/>"; echo $var2; echo "<br/>"; settype($var2,'integer'); echo $total = $var1 + $var2; echo "<br/>"; echo gettype($var1); echo "<br/>"; echo gettype($var2); echo "<br/>"; settype($var2,'integer'); echo gettype($var2); echo "<br/>"; $var1 = "The first Sentances"; $var2

Variable in PHP

Image
Variable in PHP  are like other programming, which are used for storing value in program. Like other programing language, we don't have to defined data type of the variable. For example, You can Defined string, Number etc in the variable. Just you have to write like below: $myvar1 = "This is a sentence"; $myvar2 = 23;    OR   $myvar2 = "23";   OR   $myvar2 = '23'; $myvar3 = 2.5;   OR   $myvar3 = "2.5";  OR   $myvar3 = '2.5'; For display the above value use echo/ print function. <?php echo $myvar1;   ?> ################################################ PHP Code ################################################ <html> <head> <title>Variable in PHP</title> </head> <body> <?php /* variable is case sensative variable start with a $ sign followed by letters or underscore they can contain letters, numbers, underscores or dashes

A basic PHP Program

Image
Here we are going to understand basic PHP program within  a HTML Code. Follow the program to Understand: Comments on PHP Printing a word using PHP print and echo function in PHP, These function are used for displaying a Text, word or a variable. Some times its also used to display return value from the function, which will be understand later in the Blog. Function are the pre-defined a Block of code, which makes you easy to write program. This is also cover later in the blog. A Browser only display HTML, and server by the use of Apache execute the PHP and makes HTML to display on the Browser.  Some Example of are "Opera", "Google Chrome", "Mozila Firefox". Use as many as Space, Tabs and new line in PHP code. This is called Best Proctise to write a Code in any language, as They are readable and more clear then write withouts spaces and etc. ###############################################    PHP Code ######################################

Moving WordPress from one Location to Another Location

Whether you are moving WordPress to a new server or to a different location on your server, you don't need to reinstall. WordPress is flexible enough to handle all of these situations. Moving to a New Server If you are moving WordPress from one server to another, begin by backing up your WordPress directory, images, plugins, and other files on your site as well as the database. See WordPress Backups and Backing Up Your Database. Here is a simple guide to moving your WordPress site to a new server that describes the process. Keeping Your Domain Name and URLs Moving your domain without changing the Home and Site URLs of your WordPress site is very simple, and in most cases can be done by moving the files. If database and URL remain the same, you can move by just copying your files and database. If database name or user changes, edit wp-config.php to have the correct values. If you want to test before you switch, you must temporarily change "siteurl" and "

Move your Magento site from one hosting account to another

Image
Follow these steps to transfer Magento from one account to another: Step 1: Backup the Magento MySQL Database Step 2: Transfer all Magento Files Step 3: Adjust the Magento Configuration Step 4: Restore the Magento Database STEP 1 Backup the Magento MySQL Database On SiteGround servers you have phpMyAdmin included by default in cPanel for your account. In other cases you will have to use the same tool or a similar one that is capable of exporting your MySQL database. Detailed information on how to perform a MySQL backup can be found in our MySQL Tutorial. Alternatively, if you don’t have phpMyAdmin installed but you have shell access you can use the mysqldump tool. The syntax is as follows: mysqldump -h HOST -u USER -p DATABASENAME > FILENAME.sql where: HOST is the database server hostname or it can be omitted if you are running the MySQL server locally USER - a user with full privileges to the Magento database DATABASENAME - is the full name of the database whic