Go Back   Forum Care Forums > Development Reference Area > Php Development

Reply
 
LinkBack Thread Tools Display Modes
PHP5 oop question...
Old
  (#1)
Andrei
Guest
 
Posts: n/a
Default PHP5 oop question... - 06-02-2007, 08:55 PM


Hi list,

I have a cl*** which I use to parse simple bbcode inside some comments.
I noticed on PHP5 that scope of preg_replace function is changed
when function is called inside a cl***. To the point:

Code:
cl*** PHS_editor
{
...

function parse_content( $str = null )
{
$from_arr = array( "@\[B\](.*?)\[\/B\]@sim",
"@\[U\](.*?)\[\/U\]@sim", "@\[I\](.*?)\[\/I\]@sim",
"@\[URL=([^\]]*)\]([^\[]*?)\[\/URL\]@sim",
"@\[IMG=([^\]]*)\]@semi",
"@\[QUOTE=([^\]]*)\]([^\[]*?)\[\/QUOTE\]@semi"
);

$to_arr = array( '<b>\1</b>', '<u>\1</u>', '<i>\1</i>',

'<a href="\1" target="_blank">\2</a>',

"'<img src=\"'.stripslashes(
\*$this->get_image_location*( '\\1' ) ).'\" border=\"0\">'",

"'<table width=\"98%\" align=\"center\"
cellpadding=\"1\" cellspacing=\"0\" border=\"0\" cl***=\"form_type\">".
"<tr>".
"<td cl***=\"maintext\">'.stripslashes(
\*$this->remove_mytags*( '\\2' ) ).'</td>".
"</tr>".
"</table>'"

);

if( is_null( $str ) )
$str = $this->editor_content;

return preg_replace( $from_arr, $to_arr, str_replace( "  ", "
&nbsp;", nl2br( $str ) ) );
}

...
}
When it gets to parse [IMG] tags I get "Fatal error: Using $this
when not in object context in ...". So it seems they changed the scope
for preg_replace callback functions. As this function is called inside
the method shouldn't it have the scope of the cl***?
Is there a workaround for this? I cannot declare a function
get_image_location which will staticly call the method bcuz I use
variables from instanced cl***.

Thnx,
Andy


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

[PHP] alert pcinfinity
Old
  (#2)
Heiko Sudar
Guest
 
Posts: n/a
Default [PHP] alert pcinfinity - 06-02-2007, 08:55 PM

hi all,

does someone ever hear of an internet explorer alert "pcinfinity"?
I really didn´t find anything in forums and search engines, so maybe
somebody in this list knows better...

thanks for answers
heiko

-----------------------------------------------
„lernen ist wie rudern gegen den strom –
hört man damit auf, treibt man zurück!“
(laotse)
-----------------------------------------------
heiko sudar
kranzhornstraße 4a
85567 grafing

08092 860585 (t)
08092 860587 (f)
0179 6863181 (m)

www.countingstation.de
www.applico.biz
www.lokalitaeten.net
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] PHP5 oop question...
Old
  (#3)
Stut
Guest
 
Posts: n/a
Default Re: [PHP] PHP5 oop question... - 06-02-2007, 08:55 PM

Andrei wrote:
> Hi list,
>
> I have a cl*** which I use to parse simple bbcode inside some comments.
> I noticed on PHP5 that scope of preg_replace function is changed
> when function is called inside a cl***. To the point:
>
>
Code:
> cl*** PHS_editor
> {
>     ...
>
>     function parse_content( $str = null )
>     {
>         $from_arr = array( "@\[B\](.*?)\[\/B\]@sim",
> "@\[U\](.*?)\[\/U\]@sim", "@\[I\](.*?)\[\/I\]@sim",
>                            "@\[URL=([^\]]*)\]([^\[]*?)\[\/URL\]@sim",
>                            "@\[IMG=([^\]]*)\]@semi",
>                            "@\[QUOTE=([^\]]*)\]([^\[]*?)\[\/QUOTE\]@semi"
>                             );
>
>         $to_arr = array( '<b>\1</b>', '<u>\1</u>', '<i>\1</i>',
>
>                          '<a href="\1" target="_blank">\2</a>',
>
>                          "'<img src=\"'.stripslashes(
> \*$this->get_image_location*( '\\1' ) ).'\" border=\"0\">'",
>
>                          "'<table width=\"98%\" align=\"center\"
> cellpadding=\"1\" cellspacing=\"0\" border=\"0\" cl***=\"form_type\">".
>                           "<tr>".
>                             "<td cl***=\"maintext\">'.stripslashes(
> \*$this->remove_mytags*( '\\2' ) ).'</td>".
>                          "</tr>".
>                          "</table>'"
>
>                          );
>
>         if( is_null( $str ) )
>             $str = $this->editor_content;
>
>         return preg_replace( $from_arr, $to_arr, str_replace( "  ", "
> &nbsp;", nl2br( $str ) ) );
>     }
>
>     ...
> }
>
>
> When it gets to parse [IMG] tags I get "Fatal error: Using $this
> when not in object context in ...". So it seems they changed the scope
> for preg_replace callback functions. As this function is called inside
> the method shouldn't it have the scope of the cl***?
> Is there a workaround for this? I cannot declare a function
> get_image_location which will staticly call the method bcuz I use
> variables from instanced cl***.


How are you trying to use this cl***? It sounds like you're trying to
use the method statically. When a method is called statically it does
not have a $this.

-Stut
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] alert pcinfinity
Old
  (#4)
Stut
Guest
 
Posts: n/a
Default Re: [PHP] alert pcinfinity - 06-02-2007, 08:55 PM

Heiko Sudar wrote:
> does someone ever hear of an internet explorer alert "pcinfinity"?
> I really didn´t find anything in forums and search engines, so maybe
> somebody in this list knows better...


I'm not sure what you mean by "internet explorer alert", but it sounds
like either advertising or you have some malware. Either way this is
definitely not the right place to ask.

-Stut
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] PHP5 oop question...
Old
  (#5)
Andrei
Guest
 
Posts: n/a
Default Re: [PHP] PHP5 oop question... - 06-02-2007, 08:55 PM


Stut wrote:
> Andrei wrote:
>> Hi list,
>>
>> I have a cl*** which I use to parse simple bbcode inside some
>> comments.
>> I noticed on PHP5 that scope of preg_replace function is changed
>> when function is called inside a cl***. To the point:
>>
>>
Code:
>> cl*** PHS_editor
>> {
>>     ...
>>
>>     function parse_content( $str = null )
>>     {
>>         $from_arr = array( "@\[B\](.*?)\[\/B\]@sim",
>> "@\[U\](.*?)\[\/U\]@sim", "@\[I\](.*?)\[\/I\]@sim",
>>                            "@\[URL=([^\]]*)\]([^\[]*?)\[\/URL\]@sim",
>>                            "@\[IMG=([^\]]*)\]@semi",
>>
>> "@\[QUOTE=([^\]]*)\]([^\[]*?)\[\/QUOTE\]@semi"
>>                             );
>>
>>         $to_arr = array( '<b>\1</b>', '<u>\1</u>', '<i>\1</i>',
>>
>>                          '<a href="\1" target="_blank">\2</a>',
>>
>>                          "'<img src=\"'.stripslashes(
>> \*$this->get_image_location*( '\\1' ) ).'\" border=\"0\">'",
>>
>>                          "'<table width=\"98%\" align=\"center\"
>> cellpadding=\"1\" cellspacing=\"0\" border=\"0\" cl***=\"form_type\">".
>>                           "<tr>".
>>                             "<td cl***=\"maintext\">'.stripslashes(
>> \*$this->remove_mytags*( '\\2' ) ).'</td>".
>>                          "</tr>".
>>                          "</table>'"
>>
>>                          );
>>
>>         if( is_null( $str ) )
>>             $str = $this->editor_content;
>>                return preg_replace( $from_arr, $to_arr, str_replace(
>> "  ", "
>> &nbsp;", nl2br( $str ) ) );
>>     }
>>
>>     ...
>> }
>>
>>
>> When it gets to parse [IMG] tags I get "Fatal error: Using $this
>> when not in object context in ...". So it seems they changed the scope
>> for preg_replace callback functions. As this function is called inside
>> the method shouldn't it have the scope of the cl***?
>> Is there a workaround for this? I cannot declare a function
>> get_image_location which will staticly call the method bcuz I use
>> variables from instanced cl***.

>
> How are you trying to use this cl***? It sounds like you're trying to
> use the method statically. When a method is called statically it does
> not have a $this.
>
> -Stut
>

Yes, method was called staticly. Strange tho in php 4 it worked.
Thnx for enlighting me with this.

Andy
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
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

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





Contact Us - Forum Care Forums - Archive - Top