I’m writing a PHP extension that takes a reference to a value and alters it. Example PHP:
$someVal = 'input value'; TestPassRef($someVal); // value now changed
What’s the right approach?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Edit 2011-09-13: The correct way to do this is to use the
ZEND_BEGIN_ARG_INFO()family of macros – see Extending and Embedding PHP chapter 6 (Sara Golemon, Developer’s Library).This example function takes one string argument by value (due to the
ZEND_ARG_PASS_INFO(0)call) and all others after that by reference (due to the second argument toZEND_BEGIN_ARG_INFObeing 1).Before adding the
convert_to_nullit would leak memory on every call (I’ve not whether this is necessary after addingZENG_ARG_INFO()calls).