[PHP] require_once

2010-09-01 Thread David Mehler
Hello,
I've got probably a simple question on require_once. I've got a file
that has require_once at the top of it pulling in another file of
functions. Later on in this file I've got another require_once
bringing in a second file. In this second file I have a function call
to a function defined in the first files' top require_once functions
file. I'm getting a call to undefined function.
Should I change he require_once to require at the top of the first
file to fix? I thought require_once meant it was in that file and
anything pulled in later?
Thanks.
Dave.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] require_once

2010-09-01 Thread Peter Lind
On 1 September 2010 08:00, David Mehler dave.meh...@gmail.com wrote:
 Hello,
 I've got probably a simple question on require_once. I've got a file
 that has require_once at the top of it pulling in another file of
 functions. Later on in this file I've got another require_once
 bringing in a second file. In this second file I have a function call
 to a function defined in the first files' top require_once functions
 file. I'm getting a call to undefined function.
 Should I change he require_once to require at the top of the first
 file to fix? I thought require_once meant it was in that file and
 anything pulled in later?
 Thanks.
 Dave.

The file is included properly, otherwise your script would halt.
You're likely looking at an issue of scope: the functions might be
included in a scope you don't expect them to be.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Backtrace in fatal error?

2010-09-01 Thread Paul Freeman
When fatal error occurs is it possible to output also the backtrace in the 
error log? The simple error message with file line 
only is quite useless...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Backtrace in fatal error?

2010-09-01 Thread Paul Freeman
When fatal error occurs is it possible to output also the backtrace in the 
error log? The simple error message with file line 
only is quite useless...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Backtrace in fatal error?

2010-09-01 Thread Simon J Welsh
I think you need a PHP extension to do this. XDebug works rather nicely for 
this.
On 31/08/2010, at 8:49 PM, Paul Freeman wrote:

 When fatal error occurs is it possible to output also the backtrace in the 
 error log? The simple error message with file line 
 only is quite useless...
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Backtrace in fatal error?

2010-09-01 Thread Richard Quadling
On 31 August 2010 09:49, Paul Freeman freem...@centrum.cz wrote:
 When fatal error occurs is it possible to output also the backtrace in the 
 error log? The simple error message with file line
 only is quite useless...

?php
namespace baz;

set_error_handler(
function($ErrNo, $ErrStr, $ErrFile, $ErrLine, $ErrContext){
echo 'An error occurred.', PHP_EOL;
var_export(debug_backtrace(true));

// Allow PHP to continue executing.
return false;
},
-1
);

register_shutdown_function(
function(){
echo 'We died a terrible death.';
var_export(debug_backtrace(true));
}
);

function bar() {
echo 'In ', __FUNCTION__, PHP_EOL;
echo 1 / 0; // Divide by zero warning.
foo();
}

function foo() {
echo 'In ', __FUNCTION__, PHP_EOL;
$a = \SNAFU; // Fatal error
}

bar();
?
outputs ...

In baz\bar
An error occurred.
array (
  0 =
  array (
'file' = 'Z:\\bad.php',
'line' = 24,
'function' = 'baz\\{closure}',
'args' =
array (
  0 = 2,
  1 = 'Division by zero',
  2 = 'Z:\\bad.php',
  3 = 24,
  4 =
  array (
  ),
),
  ),
  1 =
  array (
'file' = 'Z:\\bad.php',
'line' = 33,
'function' = 'baz\\bar',
'args' =
array (
),
  ),
)
Warning: Division by zero in Z:\bad.php on line 24
In baz\foo

Fatal error: Undefined constant 'SNAFU' in Z:\bad.php on line 30
We died a terrible death.array (
  0 =
  array (
'function' = 'baz\\{closure}',
'args' =
array (
),
  ),
)

So, it looks like extension or a core mod only.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Backtrace in fatal error?

2010-09-01 Thread freeman3
Thanks!
I didn't notice the register_shutdown_function function.
But it executes always I want to run it only to track fatal error. Also I 
can't get the backtrace properly:( I can't use 5.3 so I guess it works 
differently in 5.2

Richard Quadling wrote:

 On 31 August 2010 09:49, Paul Freeman freem...@centrum.cz wrote:
 When fatal error occurs is it possible to output also the backtrace in
 the error log? The simple error message with file line only is quite
 useless...
 
 ?php
 namespace baz;
 
 set_error_handler(
 function($ErrNo, $ErrStr, $ErrFile, $ErrLine, $ErrContext){
 echo 'An error occurred.', PHP_EOL;
 var_export(debug_backtrace(true));
 
 // Allow PHP to continue executing.
 return false;
 },
 -1
 );
 
 register_shutdown_function(
 function(){
 echo 'We died a terrible death.';
 var_export(debug_backtrace(true));
 }
 );
 
 function bar() {
 echo 'In ', __FUNCTION__, PHP_EOL;
 echo 1 / 0; // Divide by zero warning.
 foo();
 }
 
 function foo() {
 echo 'In ', __FUNCTION__, PHP_EOL;
 $a = \SNAFU; // Fatal error
 }
 
 bar();
 ?
 outputs ...
 
 In baz\bar
 An error occurred.
 array (
   0 =
   array (
 'file' = 'Z:\\bad.php',
 'line' = 24,
 'function' = 'baz\\{closure}',
 'args' =
 array (
   0 = 2,
   1 = 'Division by zero',
   2 = 'Z:\\bad.php',
   3 = 24,
   4 =
   array (
   ),
 ),
   ),
   1 =
   array (
 'file' = 'Z:\\bad.php',
 'line' = 33,
 'function' = 'baz\\bar',
 'args' =
 array (
 ),
   ),
 )
 Warning: Division by zero in Z:\bad.php on line 24
 In baz\foo
 
 Fatal error: Undefined constant 'SNAFU' in Z:\bad.php on line 30
 We died a terrible death.array (
   0 =
   array (
 'function' = 'baz\\{closure}',
 'args' =
 array (
 ),
   ),
 )
 
 So, it looks like extension or a core mod only.
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Backtrace in fatal error?

2010-09-01 Thread Richard Quadling
On 1 September 2010 13:38,  freem...@centrum.cz wrote:
 Thanks!
 I didn't notice the register_shutdown_function function.
 But it executes always I want to run it only to track fatal error. Also I
 can't get the backtrace properly:( I can't use 5.3 so I guess it works
 differently in 5.2

 Richard Quadling wrote:

 On 31 August 2010 09:49, Paul Freeman freem...@centrum.cz wrote:
 When fatal error occurs is it possible to output also the backtrace in
 the error log? The simple error message with file line only is quite
 useless...

 ?php
 namespace baz;

 set_error_handler(
     function($ErrNo, $ErrStr, $ErrFile, $ErrLine, $ErrContext){
         echo 'An error occurred.', PHP_EOL;
         var_export(debug_backtrace(true));

         // Allow PHP to continue executing.
         return false;
     },
     -1
 );

 register_shutdown_function(
     function(){
         echo 'We died a terrible death.';
         var_export(debug_backtrace(true));
     }
 );

 function bar() {
     echo 'In ', __FUNCTION__, PHP_EOL;
     echo 1 / 0; // Divide by zero warning.
     foo();
 }

 function foo() {
     echo 'In ', __FUNCTION__, PHP_EOL;
     $a = \SNAFU; // Fatal error
 }

 bar();
 ?
 outputs ...

 In baz\bar
 An error occurred.
 array (
   0 =
   array (
     'file' = 'Z:\\bad.php',
     'line' = 24,
     'function' = 'baz\\{closure}',
     'args' =
     array (
       0 = 2,
       1 = 'Division by zero',
       2 = 'Z:\\bad.php',
       3 = 24,
       4 =
       array (
       ),
     ),
   ),
   1 =
   array (
     'file' = 'Z:\\bad.php',
     'line' = 33,
     'function' = 'baz\\bar',
     'args' =
     array (
     ),
   ),
 )
 Warning: Division by zero in Z:\bad.php on line 24
 In baz\foo

 Fatal error: Undefined constant 'SNAFU' in Z:\bad.php on line 30
 We died a terrible death.array (
   0 =
   array (
     'function' = 'baz\\{closure}',
     'args' =
     array (
     ),
   ),
 )

 So, it looks like extension or a core mod only.



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



No. I think you've missed the point. Neither set_error_handler() or
register_shutdown_function() report the fatal stack.

This would need to be in an extension or a mod to the core code.

Userland code can't access it.

The stack trace shown in the shutdown function is just the shutdown
function, not why there is a shutdown.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] json_encode() behavior and the browser

2010-09-01 Thread Christoph Boget
I'm curious if the behavior of json_encode() is influenced by the
browser at all.  I have a page that returns search results.  If I
access the page and perform a search using Chrome, the following error
shows up in the log:

PHP Warning:  json_encode() [a
href='function.json-encode'function.json-encode/a]: Invalid UTF-8
sequence in argument in [PAGE] on line [LINE]

If I access the page and perform a search, the exact same search using
the exact same parameters, using Firefox then I get the expected
results.  When I var_dump() the return value of json_encode(), I see
that it is a null in the case where I accessed using chrome but the
expected string in the case where I accessed using firefox.  In both
cases, the input array is identical.

Given the identical input and different output, the only thing I can
figure is that the headers sent to the server as part of the request
figure in to how json_encode() behaves.  Is that the case?  Or am I
barking up the wrong tree?

To be clear, I'm not talking about how the browser ultimately handles
the json encoded data.  I know there can be issues with that.  I'm
talking about the process before the data is even shipped to the
browser -- about how json_encode() behaves when executed as part of
the PHP script.

thnx,
Christoph

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: json_encode() behavior and the browser

2010-09-01 Thread Jo�o C�ndido de Souza Neto
It can have something to do with your browser codification (UTF8, 
ISO-8859-???).

-- 
João Cândido de Souza Neto

Christoph Boget cbo...@hotmail.com escreveu na mensagem 
news:aanlkti=45-heto2myhq116gv6bfxvdba_yxfzjnqk...@mail.gmail.com...
 I'm curious if the behavior of json_encode() is influenced by the
 browser at all.  I have a page that returns search results.  If I
 access the page and perform a search using Chrome, the following error
 shows up in the log:

 PHP Warning:  json_encode() [a
 href='function.json-encode'function.json-encode/a]: Invalid UTF-8
 sequence in argument in [PAGE] on line [LINE]

 If I access the page and perform a search, the exact same search using
 the exact same parameters, using Firefox then I get the expected
 results.  When I var_dump() the return value of json_encode(), I see
 that it is a null in the case where I accessed using chrome but the
 expected string in the case where I accessed using firefox.  In both
 cases, the input array is identical.

 Given the identical input and different output, the only thing I can
 figure is that the headers sent to the server as part of the request
 figure in to how json_encode() behaves.  Is that the case?  Or am I
 barking up the wrong tree?

 To be clear, I'm not talking about how the browser ultimately handles
 the json encoded data.  I know there can be issues with that.  I'm
 talking about the process before the data is even shipped to the
 browser -- about how json_encode() behaves when executed as part of
 the PHP script.

 thnx,
 Christoph 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: json_encode() behavior and the browser

2010-09-01 Thread João Souza
You should set the charset of your page by meta tag in its head.


2010/9/1 Christoph Boget christoph.bo...@gmail.com

  It can have something to do with your browser codification (UTF8,
  ISO-8859-???).

 But why would that be the case?  Is json_encode() actually encoding
 the string differently in each case?  And would it encode it
 differently if I wrote a script to take the same input and ran it from
 the command line?

 Is there a way I can get around this on the back end?  Make it so that
 it'll behave the same in all cases?

 thnx,
 Christoph




-- 
João Cândido de Souza Neto


Re: [PHP] Re: json_encode() behavior and the browser

2010-09-01 Thread Christoph Boget
 It can have something to do with your browser codification (UTF8,
 ISO-8859-???).

But why would that be the case?  Is json_encode() actually encoding
the string differently in each case?  And would it encode it
differently if I wrote a script to take the same input and ran it from
the command line?

Is there a way I can get around this on the back end?  Make it so that
it'll behave the same in all cases?

thnx,
Christoph

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: json_encode() behavior and the browser

2010-09-01 Thread Christoph Boget
 You should set the charset of your page by meta tag in its head.

Do you have a source of reference to which you point me?

thnx,
Christoph

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: json_encode() behavior and the browser

2010-09-01 Thread Jo�o C�ndido de Souza Neto
http://www.w3.org/TR/html4/charset.html

I hope it can help you.

PS: json_decode works only in utf8.

-- 
João Cândido de Souza Neto

Christoph Boget cbo...@hotmail.com escreveu na mensagem 
news:aanlktikpqdckrq7ctjwccgspz-c4fxpcnxxn_u48+...@mail.gmail.com...
 You should set the charset of your page by meta tag in its head.

 Do you have a source of reference to which you point me?

 thnx,
 Christoph 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: json_encode() behavior and the browser

2010-09-01 Thread Christoph Boget
 http://www.w3.org/TR/html4/charset.html
 I hope it can help you.
 PS: json_decode works only in utf8.

I understand charsets.  I understand the difference between the
charsets.  What I don't understand is how json_encode() is taking the
*exact same input* and behaving differently (breaking in one case,
working in another) depending on the browser being used.  And taking
your statement that json_encode() works only in utf-8 as a given, how
can I guard against the different behaviors on the backend, where
json_encode() is getting executed.  Should I do some kind of header
sniffing prior to every call to json_encode() and massage the data
accordingly depending on what I find?  That seems somewhat excessive.
But based on what you are saying and based on what I'm witnessing, it
seems like there is no other way around that.

thnx,
Christoph

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: json_encode() behavior and the browser

2010-09-01 Thread Jo�o C�ndido de Souza Neto
Are you setting the charset in your html head?

If not, its using the charset set in your browser, which can be different 
from one to another.

In this case, you must set if via meta tag to avoid it.

-- 
João Cândido de Souza Neto

Christoph Boget cbo...@hotmail.com escreveu na mensagem 
news:aanlktimbfbgunifhthztp+2jnhzgmo8uqvwydq4vd...@mail.gmail.com...
 http://www.w3.org/TR/html4/charset.html
 I hope it can help you.
 PS: json_decode works only in utf8.

 I understand charsets.  I understand the difference between the
 charsets.  What I don't understand is how json_encode() is taking the
 *exact same input* and behaving differently (breaking in one case,
 working in another) depending on the browser being used.  And taking
 your statement that json_encode() works only in utf-8 as a given, how
 can I guard against the different behaviors on the backend, where
 json_encode() is getting executed.  Should I do some kind of header
 sniffing prior to every call to json_encode() and massage the data
 accordingly depending on what I find?  That seems somewhat excessive.
 But based on what you are saying and based on what I'm witnessing, it
 seems like there is no other way around that.

 thnx,
 Christoph 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: json_encode() behavior and the browser

2010-09-01 Thread Jo�o C�ndido de Souza Neto
Sorry about the error:

In this case, you must set IT via meta tag to avoid it.

-- 
João Cândido de Souza Neto

João Cândido de Souza Neto j...@consultorweb.cnt.br escreveu na 
mensagem news:16.27.07419.e0e5e...@pb1.pair.com...
 Are you setting the charset in your html head?

 If not, its using the charset set in your browser, which can be different 
 from one to another.

 In this case, you must set if via meta tag to avoid it.

 -- 
 João Cândido de Souza Neto

 Christoph Boget cbo...@hotmail.com escreveu na mensagem 
 news:aanlktimbfbgunifhthztp+2jnhzgmo8uqvwydq4vd...@mail.gmail.com...
 http://www.w3.org/TR/html4/charset.html
 I hope it can help you.
 PS: json_decode works only in utf8.

 I understand charsets.  I understand the difference between the
 charsets.  What I don't understand is how json_encode() is taking the
 *exact same input* and behaving differently (breaking in one case,
 working in another) depending on the browser being used.  And taking
 your statement that json_encode() works only in utf-8 as a given, how
 can I guard against the different behaviors on the backend, where
 json_encode() is getting executed.  Should I do some kind of header
 sniffing prior to every call to json_encode() and massage the data
 accordingly depending on what I find?  That seems somewhat excessive.
 But based on what you are saying and based on what I'm witnessing, it
 seems like there is no other way around that.

 thnx,
 Christoph

 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: json_encode() behavior and the browser

2010-09-01 Thread Christoph Boget
 Sorry about the error:
 In this case, you must set IT via meta tag to avoid it.

Ok, let's try this using a different approach.  Consider the following
pseudo-code:

?php
$result = mysql_query( 'SELECT name, date FROM table WHERE field = value' );
$array = array();
while( $row = mysql_fetch_assoc( $result ))
{
  $array[] = $row;
}

$string = json_encode( $array );
?

Why does the charset of the browser matter one whit to the value of
either $row['name'] or $row['date'] such that it would break
json_encode() in one case and not the other.  Is it that PHP is taking
the string which is returned as part of the result set and encoding it
to match the charset passed in from the browser?

thnx,
Christoph

* Disclaimer : the actual code (and data repository) I am using is
slightly different from the above but is similar enough so that it's a
valid representation

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: json_encode() behavior and the browser

2010-09-01 Thread Jo�o C�ndido de Souza Neto
In this case, you are right. It has nothing to do with the browser.

You´ll need a more detailed debug so you can see excatly what´s happening.

-- 
João Cândido de Souza Neto

Christoph Boget cbo...@hotmail.com escreveu na mensagem 
news:aanlktikctht0nxz1hi0ezj=i2m3716wepd=deppke...@mail.gmail.com...
 Sorry about the error:
 In this case, you must set IT via meta tag to avoid it.

 Ok, let's try this using a different approach.  Consider the following
 pseudo-code:

 ?php
 $result = mysql_query( 'SELECT name, date FROM table WHERE field = 
 value' );
 $array = array();
 while( $row = mysql_fetch_assoc( $result ))
 {
  $array[] = $row;
 }

 $string = json_encode( $array );
 ?

 Why does the charset of the browser matter one whit to the value of
 either $row['name'] or $row['date'] such that it would break
 json_encode() in one case and not the other.  Is it that PHP is taking
 the string which is returned as part of the result set and encoding it
 to match the charset passed in from the browser?

 thnx,
 Christoph

 * Disclaimer : the actual code (and data repository) I am using is
 slightly different from the above but is similar enough so that it's a
 valid representation 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] 'dl() is deprecated' Error in PHP5.2.3

2010-09-01 Thread Bruce Bailey

Hi

Can someone explain to me why I'm getting the 'dl() is deprecated' error? 
I'm running PHP5.2.3 and I believe that I have the php.ini settings correct:

error.log:[2010-08-24T13:38:53] bPC Error/b: dl() 
#91;function.dl#93;: dl() is deprecated - use extension=test.so in your 
php.ini


bash-2.05b$ php --version
PHP 5.2.3 (cli) (built: May  4 2009 16:23:02)

bash-2.05b$ php -i | grep -i safe
Thread Safety = disabled
safe_mode = Off = Off
safe_mode_exec_dir = no value = no value
safe_mode_gid = Off = Off
safe_mode_include_dir = no value = no value
sql.safe_mode = Off = Off


bash-2.05b$ php -i | grep -i dl
enable_dl = On = On

I thought that 'dl' wasn't deprecated until version 5.3.x

Thanks in advance,

Bruce

  

[PHP] Re: require_once

2010-09-01 Thread freeman3
I think the files included just when you call it to include. How do you mean 
it later?
What's in that file? A class or direct code?

David Mehler wrote:

 Hello,
 I've got probably a simple question on require_once. I've got a file
 that has require_once at the top of it pulling in another file of
 functions. Later on in this file I've got another require_once
 bringing in a second file. In this second file I have a function call
 to a function defined in the first files' top require_once functions
 file. I'm getting a call to undefined function.
 Should I change he require_once to require at the top of the first
 file to fix? I thought require_once meant it was in that file and
 anything pulled in later?
 Thanks.
 Dave.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: error_log file error reporting level

2010-09-01 Thread freeman3
I don't know that too.
I think the solution is to use your own error handler and save error in some 
another file.

hovnocuc wrote:

 Hello,
 
 [ Question ]
 How do I force error_log to log only errors specified in the
 error_reporting directive? Is it even possible or did I get something
 wrong? I have one old script which uses ereg and the awesome size of the
 error log is getting on my nerves.
 
 [ Current ini config ]
 error_reporting = E_ALL  ~E_DEPRECATED  ;;or E_ALL ^ E_DEPRECATED
 display_errors = Off
 log_errors = On
 error_log = /var/log/php-fpm/php-errors.log
 
 [ PHP ]
 5.3.3 + suhosin patch 5.3.3-0.9.10 + suhosin extension 0.9.32.1
 pecl: imagick-3.0.1RC1, APC-3.1.3p1, geoip-1.0.7, rar-2.0.0
 php configure: in the appendix
 
 [ Expected result ]
 php-errors.log containing all errors EXCEPT deprecated notices
 
 [ Actual result ]
 
  PHP Deprecated:  Function ereg() is deprecated in ...
 
 
 [ Notes ]
 I know which ini php loads, so yeah.. I'm actually using the same that
 I'm configuring.
 I'm not using syslog, but a file. See Current ini config above.
 
 
 Thank you for your time.
 
 [ Appendix ]
 ../configure --prefix=/usr --enable-fpm --disable-rpath --with-pear
 --disable-debug --with-openssl --with-pcre-regex --with-zlib
 --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif
 --enable-inline-optimization --with-gd --with-jpeg-dir --with-png-dir
 --with-freetype-dir --with-gettext --with-imap --with-imap-ssl
 --with-kerberos --enable-mbstring --enable-mbregex --with-mcrypt
 --with-mysql --with-mysqli --enable-pdo --with-pdo-mysql
 --with-pdo-pgsql --with-pgsql --enable-shmop --enable-soap
 --enable-sockets --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvsem
 --enable-sysvshm --with-tidy --enable-wddx --with-xmlrpc --with-xsl
 --enable-zip --enable-ftp --enable-dom --enable-xmlwriter
 --enable-xmlreader --enable-tokenizer --enable-simplexml
 --enable-session --enable-posix --enable-phar --enable-libxml
 --enable-json --with-iconv --enable-filter --enable-fileinfo
 --enable-ctype


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Removing link on the fly, but leave link text

2010-09-01 Thread Karl DeSaulniers


On Aug 31, 2010, at 3:06 PM, Ashley Sheridan wrote:


On Tue, 2010-08-31 at 15:01 -0500, Karl DeSaulniers wrote:


On Aug 31, 2010, at 2:32 PM, Ashley Sheridan wrote:

 On Tue, 2010-08-31 at 14:31 -0500, Karl DeSaulniers wrote:

 Hi,
 Say I have some text.

 $text = 'You can logon here: a href=http://website.com/shop/
 index.php?username='.$username.'http://website.com/shop/ 
index.php?

 username='.$username.'/a. This link will take you to your web
 browser to login.'.$eol;

 I want to be able to strip the a href=http://website.com/shop/
 index.php?username='.$username.' and /a.
 Leaving just the http://website.com/shop/index.php?username='.
 $username.' text, so it would end up like.


 $text = 'You can logon here: http://website.com/shop/index.php?
 username='.$username.'. This link will take you to your web  
browser

 to login.'.$eol;

 I have tried MANY different ways and have no success.
 Can anyone help me?
 TIA


 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com


 strip_tags() will do the job here.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk



Hi Ash,
I tried that, but it did not work.
I do not want it to strip all tags, just the a href=/a. so if
there was a p or br /. I don't want those removed.
There is more text than just what I posted.

This is what I am trying currently.
This is someones code from a forum that I am trying to adopt.

//CODE start
function strip_only($str, $tags) { // Thanks Steve
 if(!is_array($tags)) {
 $tags = (strpos($str, '') !== false ? explode('',
str_replace('', '', $tags)) : array($tags));
 if(end($tags) == '') array_pop($tags);
 }
 foreach($tags as $tag) $str = preg_replace('#/?'.$tag.'[^]
*#is', '', $str);
 return $str;
}

$str = 'p style=text-align:centerParagraph/pstrongBold/
strongbr/span style=color:redRed/spanh1Header/h1';

echo strip_only($str, array('p', 'h1'));
echo strip_only($str, 'ph1');

//CODE end

I was using it like so.

$text = strip_only($text, array('a'));
or
$text = strip_only($text, 'a');

But got my results back like:
'You can logon here: href=http://website.com/shop/
index.php?username='.$username.'http://website.com/shop/index.php?
username='.$username.'. This link will take you to your web
browser to login.'.$eol;
uugh..

Karl DeSaulniers
Design Drumm
http://designdrumm.com



Look at the second argument to strip_tags() which allows you to  
specify a list of allowable tags. It will do what you want, you  
just need to look at the manual.


Thanks,
Ash
http://www.ashleysheridan.co.uk





Hey Ash,
I did as you suggested and still got the same results.

Results:
'You can logon here: href=http://website.com/shop/
index.php?username='.$username.'http://website.com/shop/index.php?
username='.$username.'. This link will take you to your web
browser to login.'.$eol;
Could it be because there is a ? in the string or the php variable?

Karl DeSaulniers
Design Drumm
http://designdrumm.com