Closed Thread Icon

Topic awaiting preservation: banging head -anyone know why this does not work? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12445" title="Pages that link to Topic awaiting preservation: banging head -anyone know why this does not work? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: banging head -anyone know why this does not work? <span class="small">(Page 1 of 1)</span>\

 
Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 09-24-2002 11:59

$imgregexp = '/(src=")([^"]+)(")/';
$page = {... some html document...}
$shu = 'sha';
function acallback($matches)
{
global $shu;
print('a.'. $GLOBALS['shu']. '<br />');
print('b.'. $shu. '<Br />');
return 'sha';
}

preg_replace_callback($imgregexp,'acallback',$page);

ok, that's the code.
Now, it should print something like 'a.sha<Br />' and 'b.sha<br />' (many times, since the expression is quite a few times in the document).
What it does is print 'a.<Br />' and 'b.<Br />'...

so does anybode know why in the world this is happening?
(of course the above code is a purified example. the real code was to add it to a global array... but that didn't work either.)

thank you,

Tyberius Prime

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-24-2002 12:14

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-24-2002 12:26

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 09-24-2002 12:32

only problem is that I'll need the assignment outside the function,
and darn it, this should be working.

(edit: setting it inside the function does work. but then, I'm not able to access the new value outside the function. I have a sneeking suspicion...


OK: here's the solution. acallback is defined within another function. So I have to declare my variable global in that function as well. Thank you InI.

[This message has been edited by Tyberius Prime (edited 09-24-2002).]

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-24-2002 12:39

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 09-24-2002 14:42

and they show, once again, that the whole concept of php having functions inside functions is flawed. (I don't even want to have this variable global. I just want to access the parents functions scope.)

Should teach me not to write functions where I can't see the function xxx at the top, because the code's longer than a page.

« BackwardsOnwards »

Show Forum Drop Down Menu