Showing posts with label Interview. Show all posts
Showing posts with label Interview. Show all posts

Wednesday, June 17, 2015

Some Questions

In PHP 5, what is the difference between using self and $this?

Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members.


What is Class and Object ?

A class, for example, is like a blueprint for a car. It defines the shape of the car on paper, with relationships between the different parts of the car clearly defined and planned out, even though the car doesn't exist yet .

An object, then, is like the actual Car built according to that blueprint. The data stored in the object is like the gear, wires, and metal that compose the car: without being assembled according to the blueprint, it's just a pile of stuff. However, when it all comes together, it becomes an organized, useful car in running condition .

What is difference Between SOAP and REST 


Read here in detailed answer



Saturday, April 5, 2014

How to UPLOAD image in Database

  there is main problem
how can i upload image in databse there is two way for uploading image in database

1.image uploading using blob
2.image uploading using folder


1.image uploading using blob

in this method  you have to create two files first upload.php and second is upload1.php.
upload.php

<form method="post" enctype="multipart/form-data">

<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">

<tr>

<td width="246">

<input type="hidden" name="MAX_FILE_SIZE" value="2000000">

<input name="userfile" type="file" id="userfile">

</td>

<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>

</tr>

</table>

</form>





Upload1.php


<?php

if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)

{

$fileName = $_FILES['userfile']['name'];

$tmpName  = $_FILES['userfile']['tmp_name'];

$fileSize = $_FILES['userfile']['size'];

$fileType = $_FILES['userfile']['type'];

$fp      = fopen($tmpName, 'r');

$content = fread($fp, filesize($tmpName));

$content = addslashes($content);

fclose($fp);

if(!get_magic_quotes_gpc())

{

    $fileName = addslashes($fileName);

}

include 'library/config.php';

include 'library/opendb.php';

$query = "INSERT INTO upload (name, size, type, content ) ".

"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

mysql_query($query) or die('Error, query failed');

include 'library/closedb.php';

echo "<br>File $fileName uploaded<br>";

}

?>

Monday, March 24, 2014

PHP Interview Questions.


 PHP Interview Questions.

 As PHP language is in trend nowadays that’s why all web developing companies give priority to those candidates who are good in PHP language. These companies hire the desired candidates who have a good knowledge of HTML language as well as PHP language & ask them the following PHP Interview Questions.

Frequently Asked PHP Interview Questions

What is PHP?
PHP is an open source scripting language which is widely used nowadays. The full form of PHP is Hypertext Pre-processor.

What is a PHP File?
Those files which contain text, HTML, JavaScript code, and PHP code are known as PHP files. The default file extension of PHP files is “.php”.

What is the current version of PHP, Apache, MySQL?
The current version of PHP is php 5.1.2, the current version of Apache is Apache 2.1 and the current version of MySQL is MySQL 5.1.

What are the uses of PHP language?
The main uses of PHP language are following:-
1. PHP language is used to generate dynamic page content.
2. Through PHP language user can create, open, read, write, and close files on the server.
3. User can collect form data through PHP language.
4. You can send and receive cookies with the help of PHP language.
5. User can add, delete and modify data in your database through PHP language.

Why we use PHP over other languages?
We use PHP language over other languages beacuse PHP language runs on different platforms like Windows, Linux, Unix, Mac OS X, etc. It is also compatible on all servers like Apache, IIS, etc.

In PHP language, what does a special set of tags <?= and ?> do?
The use of special set of tags in PHP language is to display the output of the program directly to the browser.

What is the common difference b/w include and require in PHP language?
In PHP language the functions include and require are used to handle the failures in a program. The common diffrence between include and require in PHP language is that in case of include function, if the file of any program is not found by include() then it shows a warning to the user but side by side the execution of the script will continue. In case of require function in PHP language, if the file of any program is not found by the rquire() then it shows a fatal error to the user and also it halt the execution of the script.

Monday, January 20, 2014

PHP with OOPS

here you have to construct two PHP files 

----------------------------------------------------------------------------------------------

 index.php

<?php
include("connection.php");
$obj=new apoo;
if(isset($_POST['SUB']))
{
   
    $un=$_POST['uname'];
    $up=$_POST['upass'];
   
    $yyy=$obj->AddUss($un,$up);
    }
//header("location:registration.php");
    ?>

<html>
<body>
<form method="post" action="">
username
<input type="text" name="uname" />
password

<input type="text" name="upass" />

<input type="submit" name="SUB" />

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


--------------------------------------------------------------------------------------------------------

connection.php


<?php

session_start();
class CLASSNAME
{
    var $connect;
    function __construct()
    {
        $this->connect=new MySQLi("localhost","root","","sun12k");
        echo "success";
    }
  
    function AddUss($un,$up)
    {
        $addU=$this->connect->prepare("insert into`nametable`(firstname,lastname)VALUES(?,?);");
        $addU->bind_param("ss",$un,$up);
        $addU->execute();
    echo "success2";
       
        //    header("location:home.php");       
        }
}
?>

How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide

How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide If you're looking to host a Laravel project on Hostinger’s hPa...