Showing posts with label 6. Show all posts
Showing posts with label 6. Show all posts

Thursday, June 2, 2016

PHP Interview Questions Part 6

1) What is the use of “Final class” and can a final class be an abstract?

(Ans) The “Final” keyword is used to make the class un-inheritable. So the class or it’s methods can not be overridden.
final class Class1 {
// ...
}

class FatalClass extends Class1 {
// ...
}

$out= new FatalClass();

An Abstract class will never be a final class as an abstract class must be extendable.

2) How can we know the number of days between two given dates using PHP?

(Ans) Simple arithmetic:
$date1 = date(‘Y-m-d’);
$date2 = ’2006-07-01?;
$days = (strtotime() – strtotime()) / (60 * 60 * 24);
echo “Number of days since ’2006-07-01?: $days”;

3)  How To Write the FORM Tag Correctly for Uploading Files?

(Ans) When users clicks the submit button, files specified in the <INPUT TYPE=FILE…> will be transferred from the browser to the Web server. This transferring (uploading) process is controlled by a properly written <FORM…> tag as:

<FORM ACTION=receiving.php METHOD=post ENCTYPE=multipart/form-data>

Note that you must specify METHOD as "post" and ENCTYPE as "multipart/form-data" in order for the uploading process to work. The following PHP code, called logo_upload.php, shows you a complete FORM tag for file uploading:

<?php

print("<html><form action=processing_uploaded_files.php"

." method=post enctype=multipart/form-data> ");

print("Please submit an image file a Web site logo for"

." fyicenter.com:<br> ");

print("<input type=file name=fyicenter_logo><br> ");

print("<input type=submit> ");

print("</form></html> ");

?>

4) Consider the following code snippet. Is this code acceptable from a security standpoint?

Assume that the $action and $data variables are designed to be accepted from the user and
register_globals is enabled.

<?php
if(isUserAdmin()) {
$isAdmin = true;
}
$data = validate_and_return_input($data);
switch($action){
case add:
addSomething($data);
break;
case delete:
if($isAdmin) {
deleteSomething($data);
}
break;
case edit:
if($isAdmin) {
editSomething($data);
}
break;
default:
print “Bad Action.”;
}
?>

A. Yes, it is secure. It checks for $isAdmin to be True before executing protected operations
B. No, it is not secure because it doesn’t make sure $action is valid input
C. No, it is not secure because $isAdmin can be hijacked by exploiting register_globals
D. Yes, it is secure because it validates the user-data $data
E. Both A and B

(Ans) The correct answer is C. This code is, by any means, not secure! In fact, it is the classic security exploit of PHP scripts using the register_globals configuration directive. The problem lies in the $isAdmin variable: although this is clearly a Boolean value, it is only set in the event that the user is an Admin and not set at all if the user is not. Because register_globals is enabled, by simply appending that variable to the end of the URL as a GET parameter, a malicious user could easily impersonate an administrator.


5) Which of the following will not combine strings $s1 and $s2 into a single string?
$s1 = a;
$s2 = b;
A. $s1 + $s2
B. "{$s1}{$s2}"
C. $s1.$s2
D. implode(, array($s1,$s2))
E. All of the above combine the strings

(Ans) You can not concatenate 2 string using “+”. The answer will be “0?; so here the answer is A.

6) Consider the following php script. What line of code should be inserted in the marked location in order to display the string php when this script is executed?

$alpha = abcdefghijklmnopqrstuvwxyz;
$letters = array(15, 7, 15);
foreach($letters as $val) {
/* What should be here */
}
A. echo chr($val);
B. echo asc($val);
C. echo substr($alpha, $val, 2);
D. echo $alpha{$val};
E. echo $alpha{$val+1}

(Ans) The answer is D. An array can be accessed like this as well. $alpha{$val}

7)  How can I execute a PHP script using command line?

(Ans) Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program.Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.

8) I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?

(Ans) PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.

9) Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?

(Ans) In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like "{$a},000,000 mln dollars", then you definitely need to use the braces.

10) What are the different types of errors in PHP?

(Ans) Here are three basic types of runtime errors in PHP:

1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script – for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all – although you can change this default behavior.

2. Warnings: These are more serious errors – for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.

3. Fatal errors: These are critical errors – for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP’s default behavior is to display them to the user when they take place.

Internally, these variations are represented by twelve different error types.

11) What is the maximum size of a file that can be uploaded using PHP and how can we change this?

(Ans) By default the maximum size is 2MB,and we can change the following setup at php.iniupload_max_filesize = 2M

12) How can we get the browser properties using PHP?

(Ans)     By using
$_SERVER[HTTP_USER_AGENT]
variable.

13) What is session_set_save_handler in PHP?

(Ans) session_set_save_handler() sets the user-level session storage functions which are used for storing and retrieving data associated with a session. This is most useful when a storage method other than those supplied by PHP sessions is preferred. i.e. Storing the session data in a local database.

14) How can I retrieve values from one database server and store them in other database server using PHP?

(Ans) We can always fetch from one database and rewrite to another.
Here is a nice solution of it.

$db1 = mysql_connect("host","user","pwd")
mysql_select_db("db1", $db1);
$res1 = mysql_query("query",$db1);$db2 = mysql_connect("host","user","pwd")
mysql_select_db("db2", $db2);
$res2 = mysql_query("query",$db2);
 At this point you can only fetch records from you previous ResultSet, i.e $res1. But you cannot execute new query in $db1, even if you supply the link as because the link was overwritten by the new db.so at this point the following script will fail.
$res3 = mysql_query("query",$db1); //this will failSo how to solve that?

Take a look below:

$db1 = mysql_connect("host","user","pwd")
mysql_select_db("db1", $db1);
$res1 = mysql_query("query",$db1);
$db2 = mysql_connect("host","user","pwd", true)
mysql_select_db("db2", $db2);
$res2 = mysql_query("query",$db2);
 So mysql_connect has another optional boolean parameter which indicates whether a link will be created or not. as we connect to the $db2 with this optional parameter set to true, so both link will remain live.

Now the following query will execute successfully.

$res3 = mysql_query("query",$db1);

 15)  How can we extract string "abc.com" from a string "mailto:info@abc.com?subject=Feedback" using regular expression of PHP?

(Ans) Try this:
$text = "mailto:info@abc.com?subject=Feedback";
preg_match(‘|.*@([^?]*)|’, $text, $output);
echo $output[1];
 Note that the second index of $output, $output[1], gives the match, not the first one, $output[0].

So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()?

Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space. Second, the more secure the crypto is, the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down, if frequent md5() generation is required.

Enjoy!

Still more to come.Wait for the next part.You can also subscribe below to receive the next part of "PHP Interview Questions" series directly in your email.

Cheers!



Tuesday, May 31, 2016

If Condition Meeting 6

Now we learn on "IF Ststement/Condition". In this example we still apply 2 files (pages) so that we can remember the previous lesson. Please pay attention to the single "if condition" below:

<html>

<head>
<title>Conditions</title>
</head>
<body>
<h3>IF Condition</h3>
<br>
Fill in a name and a exams mark[0-100] below:
<form action="seven.php" method="post">
<pre>
Nama : <input type="text" name="usrname" size="30" maxlength="30"><br><br>
Nilai : <input type="text" name="mark" size="3" maxlength="3"><br><br>
<input type="submit" value="Send Soon!">
</pre>
</form>
</body>
</html>

save the above file as six.php
Then create a script as a new file and save it as seven.php like below:

<html>
<head>
<title>Seven</title>
</head>
<body>
<h3>Thank you for entering your data</h3><br>
<h4>The marks result is:</h4>
<br>
<?php
$usrname = $_POST[usrname];
$mark = $_POST[mark];
$result = "Not Passed";
if ($mark >= 60){
$result = "Passed";
}
print("<h3>
$usrname is <font color=red><b>$result</b></font>
</h3>");

?>
</body>
</html>

Then open your browser and point to the six.php and see the result. It should show that the mark greater than or equal to 60 is "passed", if not it s "not passed".
The logic is, if the condition is "true" then the statement inside the { } bracket is executed if "false" it is not executed.

Monday, April 25, 2016

Download Clone Yourself Camera Pro v1 3 6 apk full version


link

Saturday, April 23, 2016

تحميل برنامج الحماية Malwarebytes Anti Malware Premium 2 1 6 1022

??? ???? ??????  Malwarebytes Anti-Malware Premium 2.1.6.1022

???????? ??????
Malwarebytes Anti-Malware Premium 2.1.6.1022
???? ????? ??????? ?? ????????? ????????? ?????? ?????? ?????????
???? ?????? ?? ????? ??????? ?? ????????? ????????? ?????????
????? ???? ????????? ??????
????? ??????? ?? ????? ?? ????? ?????????
?????? ????? ??? ?? ?? ???? ????? ?????????



























?????

DOWNLOAD






Saturday, March 5, 2016

6 Months Step by step Guide to make 1000 per month Download Free

 Download Free Ebook-6 months Step by step Guide to make $1000 per month


6-Months-Step-by-step-Guide-to-make-$1000-per-month-Download-Free-ebook
6 Months Step by step Guide to make $1000 per month Download Free
A complete and ultimate guide to make $1000 per month from blogging. 
Step by Step Guide to Make 1000$ a Month Blogging is an IT related,  authorized by Hassam Ahmed Awan. This is short book of about fifty (50) pages. In this book author describes in detail, how to make a blog, free and earn a reasonable money through it.
As the title of this IT related book is very interesting and appealing. This is about blogging, how to, make a successful blog, increase its traffic and finally who to earn online, from that blog. I am also a blogger, http://infopoint11.blogspot.com/is my blog, and I am working over it since one year, but my experience says, it is true you can earn online using blog, but it requires really hard work, skills and time also.
 Sample Pages/Contents of this ebook:
6-Months-Step-by-step-Guide-to-make-$1000-per-month-Download-Free-ebook
6-Months-Step-by-step-Guide-to-make-$1000-per-month-Download-Free-ebook

Download-Free-ebook-6-Months-Step-by-step-Guide-to-make-$1000-per-month
6-Months-Step-by-step-Guide-to-make-$1000-per-month-Download-Free-ebook

Take some time to say thank u before downloading this ebook in comments.
Download-Free-ebook-6-Months-Step-by-step-Guide-to-make-$1000-per-month




Download This Book for Free

Thursday, February 25, 2016

Download AusLogics BoostSpeed 7 6 0 0 Premium full version


link

Monday, February 8, 2016

Download Laughingbird The Logo Creator 6 6 full version

free logo templates free online logos free to use logos build a logo online for free build a logo free free logo text logo free online text logo design online free free logo graphics free text logo design logos for free online
This software provide facility to create or make your own logo of your own business , it have may kinds of attractive template 
It is a good software if you want to download then click on link and fallow the page then click on direct download link that are given below above the button, 

Wednesday, February 3, 2016

Download Real Hide IP 4 4 3 6 full version


link

Tuesday, February 2, 2016

Download Internet Download Manager 6 23 build 10 with Crack

This software is used for downloading file like audio , video , software , documents and web 
Just click on direct download link and then save in to your system
link

Download VPS Pin v0 6 with key full version


link

Thursday, January 28, 2016

Download Hide IP Changer Easy 5 3 3 6 full version



link

Wednesday, January 27, 2016

Download BB FlashBack Pro 5 6 0 Build 3551 With Crack

Video maker , Movie Maker , Video editor , video joiner , screen recorder
This software is used for developing your own video , Movie maker or video recorder , to capture all your screen activity 
How to download this software like BB FlashBack Pro , Just fallow the given link under below and click on direct download link
link

Tuesday, January 26, 2016

Download Advanced Serial Port Terminal 6 0 382 Crack

Eltima Advanced Serial Port Terminal 6.0.382 + Crack + 100
Downloads Advanced Serial Port Terminal latest full version for windows
Hi friend with the help of Eltima Advanced Serial port Terminal with crack , It is an Advanced Serial Port Terminal That are used to provides simple communication interface to connect to any serial port device and allows you to open as many serial ports as you want , if you want to downloading this version of advanced serial port terminal you can click on link then fallow to the next page, 

Monday, January 25, 2016

Download Avira Free Antivirus 14 0 6 552 Offline Installer


link

Sunday, January 24, 2016

Bangla Graphics Design Book Adobe Photoshop CS3 Including Version CS1 CS2 6 0 7 0 Book Review

With the motto of "teach yourself" Bangla graphics design book or Bangla Photoshop book named Adobe Photoshop CS3 Including Version CS1, CS2, 6.0, 7.0 has been written by the prominent Bangla computer books writer Bappi Ashraf and published by Gyankosh Prokashani which is a good, pioneer and leading book to learn Photoshop by understanding graphics and its tools in Bangla language in the Bangladeshi computer books market.

Frankly speaking, with lots of practice projects and systematic description of usage of important tools in Adobe Photoshop, such book can provide a lot of useful staffs to learn graphics design and the Adobe Photoshop software in Bangla language.

Basically, it is one of the pioneer books on Graphics design in Bangla language. So, if you want to learn Adobe Photoshop or graphics design following Bangla meaning, you should read the whole review of this Bangla graphics design book. Then you may decide to collect or purchase or check out the hard copy from a standard book library near by your location.

Note: Weve a hard-copy of the book named  Adobe Photoshop CS3 Including Version CS1, CS2, 6.0, 7.0 to make the book review on it. The hard-copy edition is Sixth Edition(October-2008). Well make the review basis on this hard-copy edition. Future edition or upgrade version may be available on the market.

Book Name:  Adobe Photoshop
Writer: Bappi Ashraf
Published By: Gyankosh Prokashani
Amount of Pages: 640
First Publish: October-2002
Last Edition: Weve October-2008 edition. Future edition may be existed!
Book Price: BDT 425 with CD

Our Comment
This Bangla graphics design book named Adobe Photoshop by Bappi Ashraf seems a good graphics design book. Because, the content narrated on this book are well and broad enough. On the other hand, weve noticed many persons who have learned Adobe Photoshop by following this book. And they have learned Photoshop well. So, the result of following this book have been observed by us. So, by watching that result, we can say that it can be a good Bangla Photoshop book to learn Adobe Photoshop.

What Will You Get Basically
The writer of this book has told that he has written this book with the concept of "teach yourself". On the other hand, Photoshop is a thing which is interesting to learn. He has also told that the book is full of fan and enjoyment so that a person can learn Photoshop by himself by playing with the example projects of this book. A CD is also included with this book. In that CD you will get project related staffs.

Weve not noticed major bad side of this Bangla graphics design or Bangla Photoshop book. Basically, this book has contained a lot of project illustrations. By completion of practices of those projects will  bring you ultimate success on learning Photoshop or graphics design automatically. You just have to strict on following it.

Saturday, January 23, 2016

Download Total Uninstall Pro 6 13 0 with Crack

This software is used for uninstalling of any system software or application that are not using stage , and take space of your drive
Fro your it is link just fallow and click on direct download link