TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-27-2008, 04:19 AM   #1 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default Call Time by pass by Reference Deprecated??? :S

Code:
Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of is_array(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file
I am getting this error at:
PHP Code:
// Try & Catch Exeception
    
try {
  if (
is_array(&$meta))
  {
  
// Combines both $html & $meta with their keys and values
  
array_combine$html, &$meta);
  
  
  
  }
  }
   catch(
Exception $meta) {
    throw new 
Exeception("The Meta variable is not an Array, please change this");
    } 
__________________
VillageIdiot can have my babbies ;d

Last edited by Orc : 01-27-2008 at 05:01 AM.
Orc is offline  
Reply With Quote
Old 01-27-2008, 05:15 AM   #2 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Why are you passing by reference? Take the & away and pass by value.
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
Orc (01-27-2008)
Old 01-27-2008, 05:16 AM   #3 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
Why are you passing by reference? Take the & away and pass by value.
I thought '&' ment reference, though I wasn't for sure. Thanks at least, though could you tell me when to pass to reference? ( not classes/objects )
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 01-27-2008, 05:21 AM   #4 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

I dont fully understand refferences, I until now thought they where like C++ pointers. Go here for an explaination PHP: References Explained - Manual
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
Orc (01-27-2008)
Old 01-27-2008, 05:24 AM   #5 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
I dont fully understand refferences, I until now thought they where like C++ pointers. Go here for an explaination PHP: References Explained - Manual
I see you edited your post :P, theres a reference and deference in C++ though, and they are used for the memory address, pointing by, it's a long story really..

Edit: BLAH!!! stop editing :P Well, now that you say that now, keep editing xD
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 01-27-2008, 05:27 AM   #6 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

I am officially done editing, I don't fully understand refferences. I will take another crack at it tomorrow when I am not tired. I'm going to bed now.
__________________

Village Idiot is offline  
Reply With Quote
Old 01-27-2008, 05:28 AM   #7 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
I am officially done editing, I don't fully understand refferences. I will take another crack at it tomorrow when I am not tired. I'm going to bed now.
Ah, when you're ready to explain it, at least explain it here first xD But thanks for helping me! :D
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 01-27-2008, 09:40 AM   #8 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

If you need to pass by reference instead of value, use the referencing operator in the function declaration, instead of sending a reference at call time. Like so:

PHP Code:
do_stuff( &$var 
becomes:

PHP Code:
do_stuff$var );

function 
do_stuff( &$var 
References will not create a copy of the variable being sent, but instead use the memory handle of that variable to manipulate it. I don't know if there is actually more to know about them, but the fact that a reference to a variable points to the same variable, where as a copy points to another, different, variable (changing the reference affects the original variable, changing the copy does not).
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 01-28-2008, 09:20 PM   #9 (permalink)
The Acquainted
 
wGEric's Avatar
 
Join Date: Nov 2007
Posts: 166
Thanks: 0
wGEric is on a distinguished road
Default

Quote:
Originally Posted by xenon View Post
References will not create a copy of the variable being sent, but instead use the memory handle of that variable to manipulate it. I don't know if there is actually more to know about them, but the fact that a reference to a variable points to the same variable, where as a copy points to another, different, variable (changing the reference affects the original variable, changing the copy does not).
To expand on this, variables are only available within their scope. Scope being within a function, loop, whatever. So when you have a variable you are passing into a function through a parameter, it creates a copy of that variable in memory for use within the function because the function is not within the scope of the variable. So you can do whatever you want with the variable you passed in through a parameter and not have it change the variable outside of the function. When you pass the variable in by reference, it doesn't create the copy and extends the scope of the variable to include the function so changing it within the function changes outside of the function as well.
__________________
Eric
wGEric is offline  
Reply With Quote
Reply



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

Advanced Search
Display Modes

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

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


All times are GMT. The time now is 03:34 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design