Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


what is magic code ?

Answers were Sorted based on User's Feedback



what is magic code ?..

Answer / arvind pippal

Some special characters is called magic code,as single quote
( ' ), double quote( " ), amperson ( & ) etc. are escape by
slash its called magic quotes. Its useful for beginner
programmer

Is This Answer Correct ?    17 Yes 0 No

what is magic code ?..

Answer / james

Magic Quotes is a process that automagically escapes
incoming data to the PHP script.

Is This Answer Correct ?    12 Yes 4 No

what is magic code ?..

Answer / karthi

Magic Quotes in Action

Now lets make a simple form processor to show how machines
with magic quotes enabled will escape those potentially
risky characters. This form submits to itself, so you only
need to make one file, "magic-quotes.php" to test it out.
magic-quotes.php Code:
<?php
echo "Altered Text: ".$_POST['question'];
?>

<form method='post'>
Question: <input type='text' name='question'/><br />
<input type='submit'>

</form>

This simple form will display to you what magic quotes is
doing. If you were to enter and submit the string: Sandy
said, "It's a beautiful day outside and I like to use \'s."
You would receive the following output.
Display:
Altered Text: Sandy said, \"It\'s a beautiful day outside
and I like to use \\\'s.\"
Question:


Magic quotes did a number on that string, didn't it? Notice
that there is a backslash before all of those risky
characters we talked about earlier. After magic quotes:
A backslash \ becomes \\
A quote ' becomes \'
A double-quote " becomes \"

Now say that you wanted to remove the escaping that magic
quotes puts in, you have two options: disable magic quotes
or strip the backslashes magic quotes adds.
Removing Backslashes - stripslashes()

Before you use PHP's backslash removal function
stripslashes it's smart to add some magic quote checking
like our "Are They Enabled?" section above. This way you
won't accidentally be removing slashes that are legitimate
in the future if your PHP's magic quotes setting changes in
the future.
magic-quotes.php Code:
<?php
echo "Removed Slashes: ";
// Remove those slashes
if(get_magic_quotes_gpc())
echo stripslashes($_POST['question']);
else
echo $_POST['question'];

?>

<form method='post'>
Question: <input type='text' name='question'/><br />
<input type='submit'>

</form>

Our new output for our string containing risky characters
would now be:
Display:
Removed Slashes: Sandy said, "It's a beautiful day outside
and I like to use \'s."
Question:

Is This Answer Correct ?    4 Yes 1 No

what is magic code ?..

Answer / soyen tulas

magic codes are implement in php to help the programmer from
being malicious affect with my sql database also called as
sql injection effects.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More PHP Interview Questions

How can we connect to a mysql database from a php script?

0 Answers  


How can we know that a session is started or not?

3 Answers   Rushmore Consultancy,


<?php include ("db.php"); $result = mysql_query("SELECT ques_id FROM questionbank order by ques_id limit 5 "); while($obj=mysql_fetch_array($result)) { $ad1[$obj['ques_id']]++;//Used an array and inserted the database query results into it. } $rand_keys=array_rand($ad1,1); //Did a random array function echo "First random id = ".$ad1[$rand_keys[0]]; echo "<br>Second random id = ".$ad1[$rand_keys[1]]; ?> <!--Its not working. Have any solution for this. -->

1 Answers  


Explain the difference between session and cookies in php?

0 Answers  


What are php filters?

0 Answers  


How can we encrypt the username and password using PHP?

3 Answers   Rushmore Consultancy,


Is it possible to extend the execution time of a php script?

0 Answers  


What is inheritance in php with example?

0 Answers  


How to check whether cookies are disbled or not in the browser ? If that is the case how do you handle the sessions ?

1 Answers  


Describe session in php.

0 Answers  


Explain me difference between mysql_connect and mysql_pconnect?

0 Answers  


What is difference between readonly and constant?

0 Answers  


Categories