Monday, 16 January 2017

Remove Image tag and html content from content in php


1.Actual Content with image 

$bodycontent = "<div id='testing'>Exmple body content and <img src=\"image/image.png\"/> image none.</div><div id='testing'>Exmple body content <img src=\"image/image.png\"/> image none.</div><div id='testing'>Exmple body content <img src=\"image/image.png\"/>image none.</div>";

2.Display only content in php tags

<?php
$bodycontent = preg_replace("/<img[^>]+\>/i", "", $bodycontent);
    $bodycontent = strip_tags($bodycontent);
  echo $bodycontent;
?>




Friday, 24 June 2016

Upload Multiple Images in Codeigniter

1.Html Form

 <html>
 <head>
    <title>Upload Form</title>
</head>
<body>
<?php echo $error;?>
<?php echo form_open_multipart('photos/image_upload');?>
<input type="file" multiple name="userfile[]" size="20" />
<br /><br />
<input type="submit" value="upload" />
</form>
</body>
</html>

2.Controller Code

 function file_upload()
{      
    $this->load->library('upload');

    $files = $_FILES;
    $cpt = count($_FILES['userfile']['name']);
    for($i=0; $i<$cpt; $i++)
    {          
        $_FILES['userfile']['name']= $files['userfile']['name'][$i];
        $_FILES['userfile']['type']= $files['userfile']['type'][$i];
        $_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name'][$i];
        $_FILES['userfile']['error']= $files['userfile']['error'][$i];
        $_FILES['userfile']['size']= $files['userfile']['size'][$i];  
        $this->upload->initialize($this->upload_config());
        $this->upload->do_upload();
    }
}

private function upload_config()
{  
    //upload an image options
    $config = array();
    $config['upload_path'] = './Images/';
    $config['allowed_types'] = 'gif|jpg|png|jpeg';
    $config['max_size']      = '0';
    $config['overwrite']     = FALSE;
    return $config;
}

Monday, 7 March 2016

How to Upload base64 Encoded Image in Codeigniter





$image = base64_decode($this->input->post("image_base64_string"));
// decoding base64 string value
$image_name = md5(uniqid(rand(), true));// image name generating with random number with 32 characters
$filename = $image_name . '.' . 'png';
//rename file name with random number
$path = set_realpath('product/image/');
//image uploading folder path
file_put_contents($path . $filename, $image);
// image is bind and upload to respective folder

Sunday, 2 August 2015

Program to find prime numbers in PHP

Program to find prime numbers in PHP

<?php
//Program to find prime numbers in php

$counts =19;

for( $a = 2; $a <= $counts; $a++ )
{
for( $s = 2; $s < $a; $s++ )
{
if( $a % $s == 0 )
{
break;
}

}
if( $s == $a )
echo “Prime Number : “, $a, “<br>”;
}
?>

HERE IS THE OUTPUT

Prime Number : 2
Prime Number : 3
Prime Number : 5
Prime Number : 7
Prime Number : 11
Prime Number : 13
Prime Number : 17
Prime Number : 19

Monday, 13 April 2015

Difference Between Primary Key and Unique Key In Sql Server

Difference Between Primary Key and Unique Key In Sql Server


Both PRIMARY KEY and UNIQUE KEY enforces the Uniqueness of the values (exp: avoids duplicate values) on the columns on which it is defined.  Also these key’s can Uniquely identify each row in database table.

Here are some major difference between PRIMARY KEY and UNIQUE KEY:



PRIMARY KEY UNIQUE KEY
NULL It doesn’t allow Null values.
Because of this we refer
PRIMARY KEY = UNIQUE KEY + Not Null CONSTRAINT
Allows Null value. But only one Null value.
INDEX By default it adds a clustered index By default it adds a UNIQUE non-clustered index
LIMIT A table can have only one PRIMARY KEY Column[s] A table can have more than one UNIQUE Key Column[s]
CREATE SYNTAX Below is the sample example for defining a single column as a PRIMARY KEY column while creating a table:
CREATE TABLE dbo.Customer
(
Id INT NOT NULL PRIMARY KEY,
FirstName VARCHAR(100),
LastName VARCHAR(100),
City VARCHAR(50)
)
Below is the Sample example for defining multiple columns as PRIMARY KEY. It also shows how we can give name for the PRIMARY KEY:
CREATE TABLE dbo.Customer
(
Id INT NOT NULL,
FirstName VARCHAR(100) NOT NULL,
LastName VARCHAR(100),
City VARCHAR(50),
CONSTRAINT PK_CUSTOMER PRIMARY KEY (Id,FirstName)
)
Below is the sample example for defining a single column as a UNIQUE KEY column while creating a table:
CREATE TABLE dbo.Customer
(
Id INT NOT NULL UNIQUE,
FirstName VARCHAR(100),
LastName VARCHAR(100),
City VARCHAR(50)
)
Below is the Sample example for defining multiple columns as UNIQUE KEY. It also shows how we can give name for the UNIQUE KEY:
CREATE TABLE dbo.Customer
(
Id INT NOT NULL,
FirstName VARCHAR(100) NOT NULL,
LastName VARCHAR(100),
City VARCHAR(50),
CONSTRAINT UK_CUSTOMER UNIQUE (Id,FirstName)
)
ALTER SYNTAX Below is the Syntax for adding PRIMARY KEY CONSTRAINT on a column when the table is already created and doesn’t have any primary key:
ALTER TABLE dbo.Customer
ADD CONSTRAINT PK_CUSTOMER PRIMARY KEY (Id)
Below is the Syntax for adding UNIQUE KEY CONSTRAINT on a column when the table is already created:
ALTER TABLE dbo.Customer
ADD CONSTRAINT UK_CUSTOMER UNIQUE (Id)
DROP SYNTAX Below is the Syntax for dropping a PRIMARY KEY:
ALTER TABLE dbo.Customer
DROP CONSTRAINT PK_CUSTOMER
Below is the Syntax for dropping a UNIQUE KEY:
ALTER TABLE dbo.Customer
DROP CONSTRAINT UK_CUSTOMER

Difference Between Primary Key and Unique Key In Sql Server

Wednesday, 8 April 2015

Display Loading Image While Page Loads

Display Loading Image While Page Loads

<html>
<body>
<div class="image_loader"></div>
<table>
<tr><td>Name :</td><td>Sharanu</td></tr>
<tr><td>Profile</td><td>Website Developer</td></tr>
</table>
</body>
</html>

<style>
.image_loader {
      width: 100%;
        height: 100%;
        z-index: 5;
        position: absolute;
background: url('images/loading.gif') 50% 50% no-repeat rgb(249,249,249);
}
</style>

//create image folder for storing the image to display as per the in css path and also you can download image from this url http://sierrafire.cr.usgs.gov/images/loading.gif 

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(window).load(function() {
$(".image_loader").fadeOut("slow");
})
</script>

Friday, 20 February 2015

Generate Excel Report in Codeigniter

Generate Excel Report in Codeigniter


1.Controller file its just for examplle

$data['excel_data'] = $this->excel_model->view();  (this value with array and in model you should be create view function)

2. View file


These 3 line for generate excel report those line should be top on the view file
<?php
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="DonationList.xls"');
header('Cache-Control: max-age=0');
?>
<table width="100%" border="1">
    <tr>
        <th>Id</th>
        <th>Donor Name</th>
</tr>
<?php foreach ($excel_data as $row): ?>
    <tr>
        <td><?php echo $row->id; ?></td>
        <td><?php echo $row->name; ?></td>
</tr>
</table>

once you run this type file in Codeigniter you get downloadable excel  sheet

Generate Excel Report in Codeigniter

Monday, 16 February 2015

How To Change Ring & Vibration Settings in Yureka



Here is the solution how to make ring with vibrate in YU Yureka




If you  not found the Sound option in click Plus(+) button on the top there will show the list you just select sound it will show in the list then you can change to ring and vibrate mode it will work 100%

Wednesday, 4 February 2015

How to Install Zend Framework

How to Install Zend Framework

Detail about How to install zend framework 2 in 5 steps


1.Download the zip file using below link

https://github.com/zendframework/ZendSkeletonApplication
after downloading the zip folder extract in and copy the all folders, paste it in your project folder example path : C:\xampp\htdocs\zend

2.Download the composer exe file from this url
https://getcomposer.org/Composer-Setup.exe
and install it while instaling time if it is give the error plz
open the php.ini file form this url example :  C:\xampp\php and Uncomment the line extension=php_openssl.dll by removing the semicolon at the beginning.
Now you are good to install Composer.

3.Open command prompt and open project folder path in command prompt example : c:xampp\htdocs\zend
and paste this code and run it for updating the composer : php composer.phar self-update

4.After this it will download 100% then you paste this code and run it for install the updated composer in same command prompt like : php composer.phar install

5.Finally its installed now you can open your website link in local  like

http://localhost/zend/public/

Example Screen will show





How to install zend framework




Thursday, 20 March 2014

Send Html Email in Codeigniter / HTML Email Configuration In Codeigiter



Variables load from config Folder autoload File Helper

Example : $autoload['helper'] = array('text','html','email');



//IMP to add this below 2 line for sending html email configuration



                $email_setting = array('mailtype' => 'html');

                $this->email->initialize($email_setting);

                //IMP


                $this->email->to('admin@gmail.com');

                $this->email->from('admin@gmail.com');

                $emailmsg = "Message : Hi This is Test Mail";

                $emailmsg.= "<table width='50%' border='0'>
    <tr><td>Name : </td>
    <td>Stive Jobs </td>
   </tr>
   <tr><td>Address : </td>
   <td>#151 5th main 3rd Cross United State Of America</td>
   </tr></table>";

                $this->email->message($emailmsg);

                $this->email->send();




Send Html Email in Codeigniter / HTML Email Configuration In Codeigiter

Saturday, 30 November 2013

Login Code in PHP

In this tutorial, we create 3 php files for testing our code.

1. index.php
2. logincheck.php
3. success.php

4 Steps to create login page

1. Create table "userlist" in database "demo".
2. Create file index.php.
3. Create file logincheck.php.
4. Create file success.php.

Create file index.php.


<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form" method="post" action="logincheck.php">
<td>
<table width="100%" border="0" cellpadding="2" cellspacing="2" bgcolor="#000">
<tr>
<td colspan="3"><strong>Login Page</strong></td>
</tr>
<tr>
<td width="78">Userid / Email id</td>
<td width="6">:</td>
<td width="294"><input name="txtusername" type="text" id="txtusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="txtpassword" type="text" id="txtpassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

Creating database with table and data


CREATE TABLE `userlist` (
`id` int(4) NOT NULL auto_increment,
`username` varchar(65) NOT NULL default '',
`password` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

INSERT INTO `userlist` VALUES (1, 'admin', 'admin123');


Create logincheck.php page

<?php

$host="localhost"; // Host name
$username=""; // username
$password=""; // password
$dbname="demo"; // Database name
$tblname="userlist"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$dbname")or die("cannot select DB");

// username and password sent from form
$txtusername=$_POST['txtusername'];
$txtusername=$_POST['txtpassword'];

// To protect MySQL injection (more detail about MySQL injection)
$txtusername= stripslashes($txtusername);
$txtusername= stripslashes($txtusername);
$txtusername= mysql_real_escape_string($txtusername);
$txtusername= mysql_real_escape_string($txtusername);
$sql="SELECT * FROM $tblname WHERE username='$txtusername' and password='$txtusername'";
$result=mysql_query($sql);

// Counting table row
$row=mysql_num_rows($result);

// If  matched $txtusernameand $txtusername, table row must be 1 row
if($row==1){

// Register redirect to file "success.php"
session("txtusername");
session("txtusername");
header("location:success.php");
}
else {
echo "Invalid Username or Password";
}
?>

Create Success Page


<?php
session_start();
if(!session_is_registered(txtusername)){
header("location:index.php");
}
?>

<html>
<body>
Login Successful
</body>
</html>

PHP database Connection


<?php
$dbhost = 'localhost:1080';
$dbuser = 'username'; // in local root is default username
$dbpass = 'password';
$con = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $con )
{
  die('connection error : ' . mysql_error());
}
echo 'Connected successfully';
$sql = 'CREATE Database test_database';
$query= mysql_query( $sql, $conn );
if(! $query )
{
  die('Not create database: ' . mysql_error());
}
echo "Database created successfully\n";
mysql_close($conn);
?>

Mail Function in PHP

How to send mail in php

Mail Function in PHP


<html>

<body>

<?php

if (isset($_REQUEST['email']))

//if "email" is filled out, send email

  {

  //send email

  $email = $_REQUEST['email'] ;

  $subject = $_REQUEST['subject'] ;

  $message = $_REQUEST['message'] ;

  mail("someone@example.com", "Subject: $subject",

  $message, "From: $email" );

  echo "Thank you for using our mail form";

  }

else

//if "email" is not filled out, display the form

  {

  echo "<form method='post' action='mailform.php'>

  Email: <input name='email' type='text'><br>

  Subject: <input name='subject' type='text'><br>

  Message:<br>

  <textarea name='message' rows='15' cols='40'>

  </textarea><br>

  <input type='submit'>

  </form>";

  }

?>

</body>

</html>


Mail Function in PHP

Image Uploading in PHP

how to upload Image in PHP

File Name save as form.php

<html>
<head>
<script type="text/javascript">
function validate(){
var filevalue=document.getElementById("file").value;
var description=document.getElementById("description").value;
if(filevalue=="" || filevalue.length<1){
alert("Select File.");
document.getElementById("file").focus();
return false;
}
if(description=="" || description.length<1){
alert("File Description must not be blank.");
document.getElementById("description").focus();
return false;
}

return true;
}
</script>
</head>
<body >
<h2 align="center" >File Upload</h2>
<form action="file_upload.php" method="post" enctype="multipart/form-data" onSubmit="return validate()" >
<table align="center" >
<tr>
<td><label for="file">File:</label></td>
<td><input type="file" name="file" id="file" /></td>
</tr>
<tr>
<td><label >File Description:</label></td>
<td><input type="text" name="description" id="description" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Submit" /></td>
</tr>
<table>
</form>
</body>
</html>

Second File Name save as file_upload.php

?php
include("connect.php"); //database connection
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 1000000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "File Error : " . $_FILES["file"]["error"] . "<br />";
}
else {

echo "Upload File Name: " . $_FILES["file"]["name"] . "<br />";
echo "File Type: " . $_FILES["file"]["type"] . "<br />";
echo "File Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "File Description:: ".$_POST['description']."<br />";

if (file_exists("images/".$_FILES["file"]["name"]))
{
echo "<b>".$_FILES["file"]["name"] . " already exists. </b>";
}else
{
move_uploaded_file($_FILES["file"]["tmp_name"],"images/". $_FILES["file"]["name"]);

$loc="images/".$_FILES["file"]["name"];
$qu="insert into images.img(loc) values('$loc')";
mysql_query($qu,$con);
?>
Uploaded File:<br>
<img src="images/<?php echo $_FILES["file"]["name"]; ?>" alt="Image path Invalid" >
<?php
}
}
}else
{
echo "Invalid file detail ::<br> file type ::".$_FILES["file"]["type"]." , file size::: ".$_FILES["file"]["size"];
}
?>

Database


Database name: image
Table name : img
Table fields : imgid(int primary key, auto incr) , loc(varchar)

Wednesday, 26 June 2013

Disable Right Click, Ctrl+c and Ctrl+u



<script type="text/javascript">
function mischandler(){
return false;
}
function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
var isCtrl = false;
    document.onkeyup=function(e)
    {
    if(e.which == 17)
    isCtrl=false;
    }
    document.onkeydown=function(e)
    {
    if(e.which == 17)
    isCtrl=true;
    if((e.which == 85) || (e.which == 67) && isCtrl == true)
    {
    // alert(‘Keyboard shortcuts are cool!’);
    return false;
    }
    }
</script>


this above code copy and paste in your head its Disabled Right click, Ctl+C and Ctl+U 


Differences Between Two Dates or Timestamps in PHP


<?php
/*for finding date different begins here*/
  // Set timezone
  date_default_timezone_set("UTC");

  // PHP strtotime compatible strings
  function dateDiff($time1, $time2, $precision = 6) {
    // If not numeric then convert texts to unix timestamps
    if (!is_int($time1)) {
      $time1 = strtotime($time1);
    }
    if (!is_int($time2)) {
      $time2 = strtotime($time2);
    }

    // If time1 is bigger than time2
    // Then swap time1 and time2
    if ($time1 > $time2) {
      $ttime = $time1;
      $time1 = $time2;
      $time2 = $ttime;
    }

    // Set up intervals and diffs arrays
    $intervals = array('minute');
    $diffs = array();

    // Loop thru all intervals
    foreach ($intervals as $interval) {
      // Create temp time from time1 and interval
      $ttime = strtotime('+1 ' . $interval, $time1);
      // Set initial values
      $add = 1;
      $looped = 0;
      // Loop until temp time is smaller than time2
      while ($time2 >= $ttime) {
        // Create new temp time from time1 and interval
        $add++;
        $ttime = strtotime("+" . $add . " " . $interval, $time1);
        $looped++;
      }

      $time1 = strtotime("+" . $looped . " " . $interval, $time1);
      $diffs[$interval] = $looped;
    }

    $count = 0;
    $times = array();
    // Loop thru all diffs
    foreach ($diffs as $interval => $value) {
      // Break if we have needed precission
      if ($count >= $precision) {
break;
      }
      // Add value and interval 
      // if value is bigger than 0
      if ($value > 0) {
// Add s if value is not 1
if ($value != 1) {
 $interval .= "s";
}
// Add value and interval to times array
$times[] = $value . " " . $interval;
$count++;
      }
    }

    // Return string with times
    return implode(", ", $times);
  }
 /*for finding date different end here*/
?>
/*for echo in php*/

<?php 
echo dateDiff("2010-01-26", "2004-01-26") . "\n";
echo dateDiff("2006-04-12 12:30:00", "1987-04-12 12:30:01") . "\n";
echo dateDiff("now", "now +2 months") . "\n";
echo dateDiff("now", "now -6 year -2 months -10 days") . "\n";
echo dateDiff("2009-01-26", "2004-01-26 15:38:11") . "\n";
?>

Monday, 17 June 2013

PHP Top Interview Questions and Answers

PHP Interview Questions and Answers 



Questions 1 :  Who is the father of PHP ?

Answers : Rasmus Lerdorf is known as the father of PHP.

Questions 2 : What is the difference between $name and $$name?

Answers :  $name is variable where as $$name is reference variable like $name=sonia and $$name=singh so $sonia value is singh.

Questions 3 :  How can we submit a form without a submit button?

Answer  :  Java script submit() function is used for submit form without submit button on click call document.formname.submit()

Questions 4 :  In how many ways we can retrieve the data in the result set of MySQL using PHP?
Answer :  We can do it by 4 Ways
 1. mysql_fetch_row. ,
 2. mysql_fetch_array ,
 3. mysql_fetch_object
 4. mysql_fetch_assoc

Questions 5 :  What is the difference between mysql_fetch_object and mysql_fetch_array?

Answers :  mysql_fetch_object() is similar tomysql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).

Questions 6:  How can we extract string "pcds.co.in " from a string "http://info@pcds.co.in using regular expression of PHP?

Answers :  preg_match("/^http:\/\/.+@(.+)$/","http://info@pcds.co.in",$matches); echo $matches[1];

Questions 7 :  What are the differences between Get and post methods.

Answers :
  There are some defference between GET and POST method 1. GET Method have some limit like only 2Kb data able to send for request But in POST method unlimited data can we send 2. when we use GET method requested data show in url but Not in POST method so POST method is good for send sensetive request

Questions 8 :  How can we create a database using PHP and MySQL?

Answers : We can create MySQL database with the use of mysql_create_db("Database Name")

Questions 9 : What are the differences between require and include?

Answers :  Both include and require used to include a file but when included file not found Include send Warning where as Require send Fatal Error .

Questions 10 :  Can we use include ("xyz.PHP") two times in a PHP page "index.PHP"?

Answers :  Yes we can use include("xyz.php") more than one time in any page. but it create a prob when xyz.php file contain some funtions declaration then error will come for already declared function in this file else not a prob like if you want to show same content two time in page then must incude it two time not a prob

Questions 11: What are the different tables(Engine) present in MySQL, which one is default

Answers :  Following tables (Storage Engine) we can create

1. MyISAM(The default storage engine IN MYSQL Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type. An .frm file stores the table format. The data file has an .MYD (MYData) extension. The index file has an .MYI (MYIndex) extension. )
2. InnoDB(InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data.)
3. Merge
4. Heap (MEMORY)(The MEMORY storage engine creates tables with contents that are stored in memory. Formerly, these were known as HEAP tables. MEMORY is the preferred term, although HEAP remains supported for backward compatibility. )
5. BDB (BerkeleyDB)(Sleepycat Software has provided MySQL with the Berkeley DB transactional storage engine. This storage engine typically is called BDB for short. BDB tables may have a greater chance of surviving crashes and are also capable of COMMIT and ROLLBACK operations on transactions)
6. EXAMPLE 
7. FEDERATED (It is a storage engine that accesses data in tables of remote databases rather than in local tables. )
8. ARCHIVE (The ARCHIVE storage engine is used for storing large amounts of data without indexes in a very small footprint. )
9. CSV (The CSV storage engine stores data in text files using comma-separated values format.)
10. BLACKHOLE (The BLACKHOLE storage engine acts as a "black hole" that accepts data but throws it away and does not store it. Retrievals always return an empty result)

Questions 12:  What is use of header() function in php ?

Answers : The header() function sends a raw HTTP header to a client.We can use herder() function for redirection of pages. It is important to notice that header() must be called before any actual output is seen..

Questions 13: How can I execute a PHP script using command line?

Answers : Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument.

Questions 14:  Suppose your Zend engine supports the mode Then how can u configure your PHP Zend engine to support mode ?

Answers :  In php.ini file: set short_open_tag=on to make PHP support

Questions : 15 What is meant by nl2br()?

Answers :  Inserts HTML line breaks (<BR/>) before all newlines in a string

Questions 16 : What is htaccess? Why do we use this and Where?

Answers :  .htaccess files are configuration files of Apache Server which provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.

Questions 17: How we get IP address of client, previous reference page etc ?Questions : 18 How we get IP address of client, previous reference page etc ?

Answers :  By using $_SERVER['REMOTE_ADDR'],$_SERVER['HTTP_REFERER'] etc.

Questions 18:  What are the reasons for selecting lamp (Linux, apache, MySQL, PHP) instead of combination of other software programs, servers and operating systems?

Answers :  All of those are open source resource. Security of Linux is very very more than windows. Apache is a better server that IIS both in functionality and security. MySQL is world most popular open source database. PHP is more faster that asp or any other scripting language.

Questions 19: How can we encrypt and decrypt a data present in a MySQL table using MySQL?

Answers  :  AES_ENCRYPT () and AES_DECRYPT ()

Questions 20 : What are the features and advantages of object-oriented programming?

Answers :  One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real world than is procedural programming. It allows for more complicated and flexible interactions. OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition patterns. For some systems, an OO approach can speed development time since many objects are standard across systems and can be reused. Components that manage dates, shipping, shopping carts, etc. can be purchased and easily modified for a specific system

Questions 21:  What are the differences between procedure-oriented languages and object-oriented languages?

Answers :  There are lot of difference between procedure language and object oriented like below
  1. Procedure language easy for new developer but complex to understand whole software as compare to object oriented model 
  2. In Procedure language it is difficult to use design pattern mvc , Singleton pattern etc but in OOP you we able to develop design pattern 
  3. IN OOP language we able to ree use code like Inheritance ,polymorphism etc but this type of thing not available in procedure language on that our Fonda use COPY and PASTE
Questions 22:  What is the use of friend function?

Answers : Sometimes a function is best shared among a number of different classes. Such functions can be declared either as member functions of one class or as global functions. In either case they can be set to be friends of other classes, by using a friend specifier in the class that is admitting them. Such functions can use all attributes of the class which names them as a friend, as if they were themselves members of that class. A friend declaration is essentially a prototype for a member function, but instead of requiring an implementation with the name of that class attached by the double colon syntax, a global function or member function of another class provides the match.

Questions 23:  What is the functionality of the function strstr and stristr?

Answers :  strstr Returns part of string from the first occurrence of needle(sub string that we finding out ) to the end of string. $email= 'sonialouder@gmail.com'; $domain = strstr($email, '@'); echo $domain; // prints @gmail.com here @ is the needle stristr is case-insensitive means able not able to diffrenciate between a and A

Questions 24:  How can we convert the time zones using PHP?
Answer :  By using date_default_timezone_get and 
date_default_timezone_set function on PHP 5.1.0
<?php
// Discover what 8am in Tokyo relates to on the East Coast of the US    

// Set the default timezone to Tokyo time:
date_default_timezone_set('Asia/Tokyo');    

// Now generate the timestamp for that particular timezone, on Jan 1st, 2000
$stamp = mktime(8, 0, 0, 1, 1, 2000);    

// Now set the timezone back to US/Eastern
date_default_timezone_set('US/Eastern');    

// Output the date in a standard format (RFC1123), this will print:
// Fri, 31 Dec 1999 18:00:00 EST
echo '<p>', date(DATE_RFC1123, $stamp) ,'</p>';?>
';?>

Questions 25:  What is meant by urlencode and urldocode?

Answer : URLencode returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs. It is encoded the same way that the posted data from a WWW form is encoded, that is the same way as in application/x-www-form-urlencoded media type. urldecode decodes any %## encoding in the given string.

Questions 26: What is the difference between the functions unlink and unset?
Answer :  unlink() deletes the given file from the file system.
                 unset() makes a variable undefined.

Questions 27: What is the difference between ereg_replace() and eregi_replace()?

Answer :  eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters.eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters.\

Questions 28:  How can I know that a variable is a number or not using a JavaScript?

Answer :  bool is_numeric ( mixed var) Returns TRUE if var is a number or a numeric string, FALSE otherwise.or use isNaN(mixed var)The isNaN() function is used to check if a value is not a number.

PHP Top Interview Questions and Answers 

Deference Between Page and Post in WordPress


Key Differences with Post and Page

The differences we list below definitely have exceptions. You can use plugins or code snippets to extend the functionality of both content types. Below is the list of key differences by default.

  1. Posts are timely vs. Pages are timeless. 
  2. Posts are social vs. Pages are NOT. 
  3. Posts can be categorized vs. Pages are hierarchical. 
  4. Posts are included in RSS feed vs. Pages are not. 
  5. Pages have custom template feature vs. Posts do not


Pages

Pages are meant to be static “one-off” type content such as your about page, privacy policy, legal disclaimers, etc. While the WordPress database stores the published date of the page, pages are timeless entities. For example, your about page is not suppose to expire. Sure you can go back and make updates to it, but chances are you will not have about page 2012, about page 2013 etc. Because there is no time and date tied to pages, they are not included in your RSS feeds by default. Pages are not meant to be social in most cases thus does not include social sharing buttons, or comments.

You don’t want users to comment on your contact page, or your legal disclaimers page. Just like you probably don’t want others to tweet your privacy policy page in most cases.

Unlike posts, pages are hierarchical by nature. For example, you can have a sub pages within a page. A key example of this in action would be our Blueprint page. This feature allows you to organize your pages together, and even assign a custom template to them.

WordPress by default comes with a feature that allows you create custom page templates using your theme. This allows developers to customize the look of each page when necessary. In most themes, post and pages look the same. But when you are using your page to create a landing page, or a gallery page, then this custom page templates feature comes in very handy.

Pages also have this archaic feature called Order which lets you customize the order of pages by assigning a number value to it. However this feature is extended by plugins like Simple Page Ordering that allows you to drag & drop the order of pages.

Post

If you are using WordPress as a blog, then you will end up using posts for majority of your site’s content. Posts are content entries listed in reverse chronological order on your blog’s home page. Due to their reverse chronological order, your posts are meant to be timely. Older posts are archived based on month and year. As the post gets older, the deeper the user has to dig to find it. You have the option to organize your posts based on categories and tags.

Because WordPress posts are published with time and date in mind, they are syndicated through the RSS feeds. This allows your readers to be notified of the most recent post update via RSS feeds. Bloggers can use the RSS feeds to deliver email broadcasts through services like Aweber or MailChimp. You can create a daily and weekly newsletter for your audience to subscribe to. The very timely nature of posts make it extremely social. You can use one of the many social sharing plugins to allow your users to share your posts in social media networks like Twitter, Facebook, Google+, LinkedIn etc.

Posts encourage conversation. They have a built-in commenting feature that allows users to comment on a particular topic. You can go to your Settings » Discussion to turn off comments on older posts if you like

Thursday, 13 June 2013

Difference Between HTML 4 and HTML 5


Today we take a few steps back and take a look at some of the differences between HTML 4 and HTML5. This is intended to be a useful overview, not an exhaustive reference, but remember that things are still and always changing. We can’t deny the fact that HTML4 is the most successful markup language in the history of Internet ever. HTML5 builds on that revolutionary success. To start coding with HTML5, you don’t need to change the way you used to code in HTML4. With HTML5 you have new semantic elements, direct support for audio, video and a cool new canvas feature.



1. HTML5 Is a Work in Progress

As cool as it is to see what HTML5 can do for you, it hasn’t been standardized like HTML4. You don’t have to worry about updating pages built using HTML4. It’s more than ten years old and it’s a set standard.

If you jump into HTML5 with both feet, you’re going to be making updates. Elements and attributes are added and modified several times a year. Of course, this is dependent how much you depend on rich elements, but it’s certainly a risk you must take into consideration when using a fluid language.

Build with HTML4, play with HTML5

2. Simplified Syntax

The simpler doctype declaration is just one of the many novelties in HTML5. Now you need to write only: and this is it. The syntax of HTML5 is compatible with HTML4 and XHTML1, but not with SGML.

4. The and Elements

For good or bad, HTML5 has acknowledged the new web anatomy. With HTML5, and are specifically marked for such. Because of this, it is unnecessary to identify these two elements with a tag.

5. New and Elements
Again, HTML5 has adopted the popular web standard. and allows you to mark specific areas of your layout as such, and should have a positive effect on on your SEO in the end.

6. New and Elements

can be used for your main menu, but it can also be used for toolbars and context menus. The element is another way to arrange text and images.

7.New Forms

The new and elements are looking good. If you do much with forms, you may want to take a look at what these have to offer. 

Some Other Features
  1. HTML4 was developed by World Wide Web consortium and WHATWG (web hypertext application technology working group) and HTML5 is being developed by web hypertext application technology working group (WHATWG) and W3C HTML WG. 
  2. HTML5 brings in new elements to structure the web pages as compared to HTML4 which uses common structures such as: – header, columns etc. These new elements are: header, nav, section, article, aside, and footer.
  3. Now, each of these elements serves a unique purpose:- 
  • Header denotes the inclusion of heading, sub headings etc. which is more specific. 
  • Nav signifies both the website navigation as well as the navigation of the table of contents. 
  • Section element corresponds to a broad category of a web page. 
  • Article element symbolizes a particular section of web page such as: blog, news, testimonials etc. 
  • Aside element is used to include the content that may relate to a specific section of a document or a web page. 
  • Footer element is used to indicate important information like copyright data, the author’s name, links to other pages etc.
  1. HTML5 brings a whole new dimension to web world. It can embed video on web-pages without using any special software like Flash. 
  2. Not only videos, HTML5 is said to be capable of playing video games on the browser itself. 
  3. HTML5 is considered to be flexible to handle inaccurate syntax. HTML5 specifies the rules related to the parsing and lexing as compared to HTML4. This means that even if there is an incorrect syntax, similar result is produced by various complaint browsers. 
  4. Furthermore, HTML5 denotes to scripting of API (application programming interfaces) including new APIs like:- 

  • Drag and drop
  • Database storage offline
  • Editing of the document
  • Canvas 2D APIs, etc.

Differences Between C And C++


C++, as the name suggests, is a superset of C. As a matter of fact, C++ can run most of C code while C cannot run C++ code. Here are the 10 major differences between C++ & C

1. C follows the procedural programming paradigm while C++ is a multi-paradigm language(procedural as well as object oriented)
  • In case of C, importance is given to the steps or procedure of the program while C++ focuses on the data rather than the process. Also, it is easier to implement/edit the code in case of C++ for the same reason.
2. In case of C, the data is not secured while the data is secured(hidden) in C++
  • This difference is due to specific OOP features like Data Hiding which are not present in C.
3. C is a low-level language while C++ is a middle-level language (Relatively, Please see the discussion at the end of the post)
  • C is regarded as a low-level language(difficult interpretation & less user friendly) while C++ has features of both low-level(concentration on whats going on in the machine hardware) & high-level languages(concentration on the program itself) & hence is regarded as a middle-level language.
4. C uses the top-down approach while C++ uses the bottom-up approach
  • In case of C, the program is formulated step by step, each step is processed into detail while in C++, the base elements are first formulated which then are linked together to give rise to larger systems.
5. C is function-driven while C++ is object-driven
  • Functions are the building blocks of a C program while objects are building blocks of a C++ program.
6. C++ supports function overloading while C does not
  • Overloading means two functions having the same name in the same program. This can be done only in C++ with the help of Polymorphism(an OOP feature)
7. We can use functions inside structures in C++ but not in C.
  • In case of C++, functions can be used inside a structure while structures cannot contain functions in C.
8. The NAMESPACE feature in C++ is absent in case of C
  • C++ uses NAMESPACE which avoid name collisions. For instance, two students enrolled in the same university cannot have the same roll number while two students in different universities might have the same roll number. The universities are two different namespace & hence contain the same roll number(identifier) but the same university(one namespace) cannot have two students with the same roll number(identifier)
9. The standard input & output functions differ in the two languages
  • C uses scanf & printf while C++ uses cin>> & cout<< as their respective input & output functions
10. C++ allows the use of reference variables while C does not

  • Reference variables allow two variable names to point to the same memory location. We cannot use these variables in C programming.