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

switch form actions? not working
i want on submit to go to different pages according to the CatID

Code: <?php $CatID=$_

Not adding to db
Hi, I can't figure out why it won't add the record to the database. It's just a simple form to get

FFmpeg Images 2 Video conversion problem ??
I got folder full of images , number of images = 600 , I want to make a video which plays one image

Issues: PHP Forms -Clearing
I've tried looking online before actually asking for help, but I've been looking for about the past

LIMIT $start, 10... how to pass last value queried into next page with GET??
Ok I know how to display the first or last 10 results of a query...

$result = mysql_query(&q

Need help in log in and log out?
hi there all of u. i have recently created a site for someone. i have placed log in and log out and

Get content from table into a list, without repeating.
Alright this is kinda an odd thing, so I need some help.

I have a table "quote" wit

Unexpected T_Variable ?
Hi all,
I dont really know what I am doing!! I know I'm doing something wrong, and I know its on

Stopping page post back
I have few literal contriols in my page and a repeater too. But inspite of using update panel, postb

Certain files upload, while others do not
I want to read the data from an uploaded file. Not sure why, but it only uploads for certain files.

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