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

Receive Rosettanet Message to SAP 4.6c
Dear all ,

My customer will send the PO details by rosettanet message , Is it

PHP Display Telephone Number On Referrer
I have used the php below to show a different telephone number in the header of the site depending u

How to find OS bit version
How can I tell the person browsing my site is running 32, or 64 bit operating system?

Typing math
I've added support for typesetting math using LaTeX on the forums.

Example:
Code: [Select]

php title problem
Hi,

I am having a problem managing my page title with PHP.

Currently I have my <

shift numbers with paging
Hi

How would i be able to display 10 numbers 1 2 3 4 5 6 7 8 9 10
and when I click next

php libs/ browsercap.in
ok i have a host that refuses to stay current. they control my php settings and libs. is there a way

my sql select id and then update problem.
I need to select some auto incremented ids out of a database and then use those id in a where statem

How can you detect variable string in a massive string?
Ok guys, i need some help with this one.

I am going to be getting a large string, like 10-20

* Gridview and Detailsview in UpdatePanel, insert mode problem
I have a GridView and DetailsView working together. When a record from Gridview is selected, Detail

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