Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Sunday, November 24, 2013

PHP Assignment Operators

Assignment    Same as:
$a += $b     $a = $a + $b    Addition
$a -= $b     $a = $a - $b     Subtraction
$a *= $b     $a = $a * $b     Multiplication
$a /= $b     $a = $a / $b    Division
$a %= $b     $a = $a % $b    Modulus


$a &= $b     $a = $a & $b     Bitwise And
$a |= $b     $a = $a | $b      Bitwise Or
$a ^= $b     $a = $a ^ $b       Bitwise Xor
$a <<= $b     $a = $a << $b     Left shift
$a >>= $b     $a = $a >> $b      Right shift

PHP concatenation operator

Concatenation means adding two string a variables
example: $a = 'This is' . 'Bangladesh'

PHP Arithmatic operator

Operator  Name  Example  Result
 +  Addition  24+12  36
 -  Subtraction  24-12  12
 *  Multiplication  24*12  288
 /  Division  24/12  2
 %  Modulus  26%12  2

Thursday, November 21, 2013

PHP email functions

<?php

if (!isset($_POST['email'])) {

?>
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
Enter your email address: <input type="text" name="email" value="<?= isset($_COOKIE['email'])?$_COOKIE['email']:"enter email"; ?>">
<input type="submit" name="submit"> <br />
<small>Last saved on: <?= isset($_COOKIE['lastsave'])?date('d-m-Y h:i:s a', $_COOKIE['lastsave']):"last save not known"; ?></small>
</form>
<?php
 } else {

    if (!empty($_POST['email'])) {
        setcookie("email", $_POST['email'], mktime() + (86400 * 30), "/");
        setcookie("lastsave", time(), mktime() + (86400 * 30), "/");
        //setcookie("lastsave", time(), mktime() - 3600, "/");

        echo "Your email address has been recorded.";
    } else {
        echo "ERROR: Please enter your email address!";
    }
}


?>

Wednesday, November 20, 2013

Way to write php script

At first need to a notpad or html file then change the extension .php. Then it will be php file. Then we are ready to work with php script or coding.
At first show to php script starting
<?php -- strating

All kind of text and code or script here.

?> -- ending

We see a example,

<?php
<h1>Softandweb</h1>
echo "Hello world"
?>

we see browser through local host :
 Then we will see browsers like

Softandweb

Hello world

What is web server?

PHP is a server scripting language. It's need for run web server. Mainly php mostly work with run together. But most valuable and popular server name Apache . Also php work with Microsoft corporation ISS server. But I think most popular server name is Apache. We can practices with Apache server. Also it's easy to use. You can download Apache server and then use it download this Apache main website. Download

What is php?

PPH is a programming language that used for web development. At first it's made personal homepage as some macro. That's why this name is (Personal Home Page). Later change name and add vast features. At this moment it's a programing language. This way to easy make dynamic website. PHP abbreviation (Hypertext Preprocessor).