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

Changing files over
Just thought I'd start with the new forums looking really nice .

Ok basically I've made this

PayPal Redirect Issue
When I have my paypal button set so that is redirects to http://empiremarketing.ca/order.php,it work

Help Ordering Arrays
Hi, I have 3 arrays as shown below.

Code: $users = $this->get_latest_users();
$flir

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_
Can anyone view my code and tell me why im getting the error:
Parse error: syntax error, unexpect

Gaining access to Drop Down Menu Variable
code is below, I am creating a drop down menu. I want to echo the value selected in the drop down me

Customizing message/behavior
Hi,I'm using the ASP.NET membership/authorization controls in my application. Some parts of my appli

download directory onto C drive
I am attempting (if this is possible) to write a routine to automatically dump the contents of a dir

Extract text from string
Hi folks,

I have a string that looks like this:

aaaaaaaaaa:
bbbbbbbbbb (ccccccccc)

Prevent PHP mail( ) from appending hostname to from address
Hey guys,

I want to be able to send texts to phones via email (since each phone has their own

Random date selection
i want to select random date with time(hour+minutes+sec) where date is specified(10/22/2009) and tim

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