You are here: Daniel Dumas »

Tag : PHP

PHP Auto-Increment and Auto-Decrement Operators

The auto-increment operator designed to automatically increment the value of the variable it is attached to by 1. It is represented by a double addition symbol (++). To see it in action, run the following script:


<?php
// define $total as 10
$total = 10;
// increment it
$total++;
// $total is now 11

?>

Thus, <?php $total++; ?> is functionally equivalent to <?php
$total = $total + 1; ?>.
There’s also a corresponding auto-decrement operator (––), which does exactly the opposite:


<?php
// define $total as 10
$total = 10;
// decrement it
$total--;
// $total is now 9

?>

These operators are frequently used in loops to update the value of the loop counter.

PHP Logical Operators

Hey guys! welcome me back! yes, i am finally back again. i been away for a long time, but i am now back again in the blogosphere to share some PHP tutorials, tips and other web development ideas, tips and tricks etc.

for today i will discuss about PHP Logical Operators.

To link together related conditions in a simple and elegant manner, we can use Keep Reading…

WordPress Search and Replace

Hey everyone, I am alive again to blog after a long time haha welcome back to me. I’ve decided to blog again to make this site alive in search engines because i been out for a very long time, and my site traffic and ranks has decreased huhu.. alright so much for the blah blah..

well today I’ll share some ways on how to Search and Replace datas or texts in WordPress. this will be useful when you are transferring a wordpress blog from one domain to another or if you’ve developed a wordpress site on your localhost and you’re gonna upload it to an online server or on your own domain, of course you need to update the paths on your posts.

for example you’ve developed a wordpress site on your local machine and you installed it on http://localhost/wordpress, when you transfer the site into a live server, you need to change that path in your Keep Reading…

PHP Operators: The === Operator

PHP’s === Operator enables you to compare or test variables for both equality and type. Refer below for example.

<?php
//define variables..
$str = '9';
$int = 9;

//Returns true since both variable contains the same value..
$res = ($str==$int);

//Returns false since the two variables are not of the same type..
$res = ($str===$int);
?>

PHP Operators : Using Comparison Operators

To compare php variables to determine whether they are the same or different.. you can use PHP Comparison Operators. See below for a list of examples..

I. Define the Variables

<?php
$num1 = 9;
$num2 = 9;
$num3 = 22;
?>

A. The Less Than Operator

<?php
//Returns true if variable in the left side is less than the right..
$res = ($num1 < $num3);
//returns true..
?>

Keep Reading…

PHP Operators: Using String Concatenation Operator

You can concatenate or add strings together using the PHP string concatenation operator represented by the period sign ( . ). refer to the examples below.

<?php
// intialize variables
$username = "daniel";
$domain = "danieldumas.com";

// the variable string $username and $domain can be combine using the concatenation operator
$email_address = $username . '@'. $domain;

//the variable $email_address now contains the value "daniel@danieldumas.com"

?>

You can also concatenate simultaneously. . Keep Reading…

PHP Operators : Using Arithmetic Operators

Using Arithmetic Operators in PHP you can perform mathematical operations on PHP variables. refer to the example below.

Using PHP Arithmetic Operator

//define variables
<?php

$num1 = 50;
$num2 = 30;

//Addition
$sum = $num1 + $num2;

//Subtraction
$difference = $num1 - $num2;

//Multiplication
$product = $num1*$num2;

//Division
$quotient = $num1 / $num2;

//Modulus
$remainder = $num1 % $num2;

?>

you may also use the shorthand using the PHP Assignment Operator and Arithmetic Operator together. Keep Reading…

PHP Operators

PHP Operators are very important, if PHP variables is the building blocks of PHP programming PHP Operators is the tool that lets you do something useful with variables. php comes with many useful operators such as Assignment Operator, Arithmetic Operator, String Operator, Comparison Operator and Logical Operator. Keep Reading…

Detecting the data type of a PHP variable

Detecting the datatype of a specific PHP variable can be done by using PHP gettype() function. refer below for example.

<?php

//define variables
$on = true;
$age = 20;
$name = "daniel";
$price = 99.99;

//Returns Boolean
echo gettype($on);

//Returns String
echo gettype($name);

//Returns Integer
echo gettype($age);

//Returns Double
echo gettype($price);

?>

Keep Reading…

PHP and MySQL Basics: Saving form input in PHP variables

form can add interactivity to your site, it enables you to get information or comments from your visitors. saving a value from a form input to a php variable is very easy. refer to the example below.

Example 1: Processing forms in the same php file

Copy and Paste the code below to your text editor and save it as form.php, then run it on your localhost Keep Reading…