Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1814 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

How could I merge these three functions?

Thread title: How could I merge these three functions?
Reply    
    Thread tools Search this thread Display Modes  
06-04-2012, 10:42 PM
#1
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old

It's just a bunch of if statements.

Run them through your head with: ($user = "username") || ($user = null)

I cannot create variables that can be used outside of the function from the function? Like:

function username($user) {
if($user = null)
$deleted = "deleted";
}

Then when the function is called username($username); I can echo $deleted? Is something like this at all possible? My tests show the above wouldn't work.

Reply With Quote
06-04-2012, 11:04 PM
#2
.Nick is offline .Nick
.Nick's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 1,159
iTrader: 3 / 100%
 

.Nick is on a distinguished road

  Old

Originally Posted by Dan View Post
It's just a bunch of if statements.

Run them through your head with: ($user = "username") || ($user = null)

I cannot create variables that can be used outside of the function from the function? Like:

function username($user) {
if($user = null)
$deleted = "deleted";
}

Then when the function is called username($username); I can echo $deleted? Is something like this at all possible? My tests show the above wouldn't work.
http://php.net/manual/en/language.variables.scope.php

You could declare $deleted outside the function and then get access to it inside a function with the global keyword.

Not that I'm saying that's a good idea or anything.

Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed