Sunday, June 25, 2017

PHP string function with example...



Returns a string with backslashes in front of the specified characters
<?php 
$str = addcslashes("Hello World!","W");
echo($str); 
?>
Converts a string of ASCII characters to hexadecimal values
<?php 
$str = bin2hex("Hello World!");
echo($str); 
?>
Removes whitespace or other characters from the right end of a string
<?php
$str = "Hello World!";
echo $str . "<br>";
echo chop($str,"World!");
?>
Returns a character from a specified ASCII value
<?php
echo chr(52) . "<br>"; // Decimal value
echo chr(052) . "<br>"; // Octal value
echo chr(0x52) . "<br>"; // Hex value
?>
Splits a string into a series of smaller parts
<?php
$str = "Hello world!";
echo chunk_split($str,1,".");
?>
 
Splits a string into a series of smaller parts
<?php
$str = "Hello world! æøå";
echo $str . "<br>";
echo convert_cyr_string($str,'w','a'); 
?>

Converts a string from one Cyrillic character-set to another

<?php
$str = "Hello world! æøå";
echo $str . "<br>";
echo convert_cyr_string($str,'w','a'); 
?>
  
Decodes a uuencoded string
<?php
$str = ",2&5L;&\@=V]R;&0A `";
echo convert_uudecode($str);
?>
Encodes a string using the uuencode algorithm
<?php
$str = "Hello world!";
echo convert_uuencode($str);
?>



Returns information about characters used in a string
<?php
$str = "Hello World!";
echo count_chars($str,3);
?>
crc32()
Calculates a 32-bit CRC for a string
<?php
$str = crc32("Hello World!");
printf("%u\n",$str);
?>

Saturday, November 22, 2014

slideshow

This is my first slideshow.
...

Thursday, October 30, 2014

Create form using text box, check box, radio button, select, submit button. And display user inserted value in new PHP page (e.g. student registration/inventory/library form).



Code: registration.html

<html>
          <head>
          <title>registration from</title>
          </head>
         
          <body>
          <form method="get" action="form2.php">
                   <table align="center" height="100%" width="100%" border="2">
                   <tr height="20%">
<td colspan="3"><center><h1><b>Registration form</b></h1></center></td>
                   </tr>
                   <tr height="60%">
                             <td width="20%">&nbsp;</td>
                             <td width="60%">
                                      <table align="center" height="100%">
                                                <th>name:</th>
                                                <td>
                                                          <input type="text" name="txt_name">
                                                </td>
                                      </tr>
                  
                                      <tr>
                                                <th>User name:</th>
                                                <td>
                                                          <input type="text" name="txt_uname">
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>Password:</th>
                                                <td>
                                                          <input type="password" name="pwd">
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>Hobby:</th>
                                                <td>
<input type="checkbox" name= "check_list[]" value="reading">reading
<input type="checkbox" name= "check_list[]" value="writing">writing
<input type="checkbox" name= "check_list[]" value="playing">playing
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>City:</th>
                                                <td>
                                                           <select name="dd_city">
<option value="Rajkot">Rajkot </option>
<option value="Baroda">Baroda </option>
<option value="Mumbai">Mumbai </option>
                                                                    <option value="Pune">Pune                                                                     </option>
                                                          </select>
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>Gender:</th>
                                                <td>
                                                          <input type="radio" name="rb" value=                                                     "male">Male<br>
                                                          <input type="radio" name="rb" value=                                                     "female">Female
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>Phone no:</th>
                                                <td>
                                                          <input type="text" name="txt_phone">
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>Email:</th>
                                                <td>
                                                          <input type="text" name="txt_mail">
                                                </td>
                                      </tr>
                                      <tr>
                                                <td align="center">
                                                          <input type="submit" value="submit">
                                                </td>
                                                <td>
                                                          <input type="reset" value="reset">
                                                </td>
                                      </tr>
                             </td>
                             </table>
                             <td width="20%">&nbsp;</td>
                   </tr>
                   <tr height="20%">
<td colspan="3"><center><h2><b><i>Prepered By:Harshiv Parsana</i></b></h2></center></td>
                   </tr>
          </table>

          </form>
          </body>
         
</html>


Code: form2.php

<html>
          <head>
                   <title>harshiv</title>
          </head>
          <body>
          <form action="form2.php" method="get">
          <table border='3' height=100% width=100% align="center" style="font-   size:x-large">
                   <tr>
<td colspan="3" height=20%><center><h1><b>Registration form</b></h1></center></td>

                   </tr>
                   <tr>
                             <td width=20%>&nbsp</td>
                             <td align="justify">
                                      <?php

                                                echo "name:";
                                                $name=$_GET["txt_name"];
                                                echo " $name"." </br>";

                                                echo "Username::";
                                                $uname=$_GET["txt_uname"];
                                                echo "$uname"." </br>";
         
                                                echo "Password::";
                                                $pwd=$_GET["pwd"];
                                                echo "$pwd"." </br>";

                                                echo "hobby:";
                                                if(isset($_GET['check_list'])){
                                                if(!empty($_GET['check_list'])){

                                                foreach($_GET['check_list'] as $selected){
                                                echo $selected."</br>";
                                                }
                                                }
                                                }
                                                echo "city:";
                                                $city=$_GET["dd_city"];
                                                echo "$city"." </br>";

                                                echo "gender:";
                                                echo $_GET['rb']."</br>"; 

                                                echo "Phone no:";
                                                $Phoneno=$_GET["txt_phone"];
                                                echo "$Phoneno"." </br>";

                                                echo "Email:";
                                                $email=$_GET["txt_mail"];
                                                echo "$email"." </br>";

                                      ?>

                             </td>
                             <td width=20%>&nbsp</td>
                   </tr>
                   <tr>
<td colspan="3" height=20%><center><h2><b><i>Prepered By:Harshiv Parsana</i></b></h2></center></td>

                   </tr>
          </table>
          </form>
          </body>
</html>      



Output: