Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Function working inside a variable?!?
Old 12-09-2007, 09:29 AM Function working inside a variable?!?
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
I have the following section of code in one of my pages:

PHP Code:
 if((file_exists($fileNamePath))&&(file_exists($thumbPath)))
                {
                    echo 
'Filename is '.$fileName.'<br> Thumb is '.$thumb;
                    echo 
'<p>Filename path '.$fileNamePath.' would be deleted.<br> Thumb path '.$thumbPath.' would be deleted.';
                    
                    
$fileNameDel unlink($fileNamePath);
                    
$thumDel unlink($thumbPath);
                } 
Its supposed to assign the unlink functions to 2 variables to that they can be called later.

But it just deletes them without them even being called! I thought they should only get deleted if I were to use some code such as:

PHP Code:
if($fileNameDel) { code goes here 
etc.

Does anyone know what I should do to solve it? Ive had similar problems in the past.
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Old 12-09-2007, 01:20 PM Re: Function working inside a variable?!?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
You cannot store a future call to a function in a variable...
What you do here, is that you store the returned value of the command you called, which is either TRUE or FALSE, depending if the file could be deleted or not.

Call the function when you need it, or create a "wrapper" function that you will call later.
PHP Code:
function myDel($file$thumb){
  
$ret=false;
  
$ret=unlink($file);
  if(
$ret===TRUE){
    
$ret=unlink($thumb);
  }
  return 
$ret;

__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-09-2007, 01:32 PM Re: Function working inside a variable?!?
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
Ahhh thanks
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Reply     « Reply to Function working inside a variable?!?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13316 seconds with 12 queries