Confusing Functions


Posted on 16th Feb 2014 07:03 pm by admin

So, I've been reading up on Functions and I like them! However, I need some help using variables in functions, since it's kind of confusing.

I just made these functions:

Did you know?Explore Trending and Topic pages for more stories like this.
<?php

function Protect($var){
$var = mysql_real_escape_string(htmlentities(stripslashes($var)));
}

function Preserve($var){
$content = nl2br(str_replace(" ", "&nbsp;", $var));
}
?>


Neither of them work. Dunno why.

From what I understand...

If I do this:
function HelloThere($var){

Then when I use the function I can go...
HelloThere($hello);

And the $hello variable will be substituted for $var from when I defined the function. Am I not right, confusing, or misled? Please help!!!

Thanks.


PS I originally had this, but it didn't work:
<?php

function Protect($var){
$variable = $var;
$protect1 = mysql_real_escape_string($variable);
$protect2 = htmlentities($protect1);
$protect3 = stripslashes($protect2);
}

function Preserve($var){
$content = nl2br(str_replace(" ", "&nbsp;", $var));
}
?>
No comments posted yet

Your Answer:

Login to answer
199 Like 21 Dislike
Previous forums Next forums
Other forums

How do i use vars in an array
Hiya peeps!

How do I use a var in an array. You will see $id but it isnt working.


Echo-ing MySQL content and Keep Formatting?
I have data in my MySQL such as:

QuoteBlah blah

Blah blah

etc
but when i ech

Socket problem
Hello,

Earlier I posted about my problem with my socket script. It took up to 100% CPU usage.

Need a fuction to count entries in a field
Hi
I need a fuction to count how many times a email address is entered in to a field.

I ma

single values into sql field
i have a form which i want the user to able to select multiple answers. But i want the answers to be

Help with PHP Calendar code...
Hello, I'm new to this forum and I'm glad I found it.
I wrote this code for a PHP calendar as an

Java API in PHP?
I have an application that we use internally here at the office.

The software company provide

Wordpress IE issue
So I am trying to add the background shadow to my wordpress page. It works fine in Firefox but does

C++ API to Oracle dB
I need to perform a select command to the Oracle dB to obtain information from a table.
What libr

add 20 000 to the rowcnt
Hi ...
I need to add 20 000 to the row count but just cant find a way to do this i am new to php

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash