php-general Digest 14 Mar 2011 07:43:24 -0000 Issue 7225
php-general Digest 14 Mar 2011 07:43:24 - Issue 7225 Topics (messages 311823 through 311825): Help for pear 311823 by: Alejandro Crosa Probem with go-pear.bat 311824 by: Alejandro Crosa 311825 by: Tommy Pham Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- HiI try execute the go-pear.bat file to open the pear set up, but I get the error messaje The go-pear.phar.dll is not a valid image of windows. Any help is very important form me. Thanks ---End Message--- ---BeginMessage--- Hi...I try install pear by executing the go-pear.bat file, but I get a follow message: The go.pear.phar.dll is not a image valid of windows. Please, any help is important for me. Thanks. Alejandro ---End Message--- ---BeginMessage--- On Sun, Mar 13, 2011 at 5:49 PM, Alejandro Crosa alec...@ymail.com wrote: Hi...I try install pear by executing the go-pear.bat file, but I get a follow message: The go.pear.phar.dll is not a image valid of windows. Please, any help is important for me. Thanks. Alejandro See http://pear.php.net/manual/en/installation.getting.php ---End Message---
php-general Digest 14 Mar 2011 20:31:21 -0000 Issue 7226
php-general Digest 14 Mar 2011 20:31:21 - Issue 7226 Topics (messages 311826 through 311836): Handling exit in eval 311826 by: Thomas Björk 311827 by: Thomas Björk 311828 by: Richard Quadling 311829 by: Richard Quadling 311830 by: Thomas Björk 311834 by: Richard Quadling assistance with php not running properly 311831 by: Jack PHP Fatal error: Cannot redeclare class 311832 by: Brendan_Crowley.DellTeam.com 311833 by: Daniel Brown 311835 by: Brendan_Crowley.DellTeam.com Deleting elements from the middle of an array 311836 by: Paul M Foster Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Is there any way to emulate an exit in eval without exiting the calling script. ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; eval($s); echo Never comes here; ? I would like to do something like this: ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; function MakeItStop() { // Do something to make the eval stop // without halting the script } $s = str_replace('exit;', 'MakeItStop();', $s); eval($s); echo Never comes here; ? A simple return would fix it IF the return isn't located within a function. Any good suggestions? Thanks in advanced Thomas Björk ---End Message--- ---BeginMessage--- Is there any way to emulate an exit in eval without exiting the calling script. ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; eval($s); echo Never comes here; ? I would like to do something like this: ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; function MakeItStop() { // Do something to make the eval stop // without halting the script } $s = str_replace('exit;', 'MakeItStop();', $s); eval($s); echo Never comes here; ? A simple return would fix it IF the return isn't located within a function. Any good suggestions? Thanks in advanced Thomas Björk ---End Message--- ---BeginMessage--- 2011/3/14 Thomas Björk t...@bytecode.se: Is there any way to emulate an exit in eval without exiting the calling script. ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; eval($s); echo Never comes here; ? I would like to do something like this: ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; function MakeItStop() { // Do something to make the eval stop // without halting the script } $s = str_replace('exit;', 'MakeItStop();', $s); eval($s); echo Never comes here; ? A simple return would fix it IF the return isn't located within a function. Any good suggestions? Thanks in advanced Thomas Björk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Can you provide a more realistic example? Just don't code anything after the last line of code that contains the exit? Surely. http://uk.php.net/manual/en/function.eval.php does say that ... A return statement will immediately terminate the evaluation of the string . So, there's your answer I suppose. Replace exit with return. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY ---End Message--- ---BeginMessage--- 2011/3/14 Richard Quadling rquadl...@gmail.com: And where is my UNDO button. Essentially, having exit in the eval code is no different to having it in non-eval code. eval isn't a separate entity which can be terminated. So, code the eval code differently. If you can provide some examples, maybe we can come up with a better solution. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY ---End Message--- ---BeginMessage--- Richard Quadling wrote: 2011/3/14 Richard Quadling rquadl...@gmail.com: And where is my UNDO button. Essentially, having exit in the eval code is no different to having it in non-eval code. eval isn't a separate entity which can be terminated. So, code the eval code differently. If you can provide some examples, maybe we can come up with a better solution. I'm developing a kind of sandbox where you will be able to run a script without affecting your current context. The script is loaded and parsed which gives me the opportunity to allow or deny functions and classes used in the script. The only problem I have so far is the exit function which, it if is allowed, terminates the calling script as well as the eval'ed script. By using a return the problem is solved as long as the user doesn't write a function containing an exit. Here is a simple script thet the user might write (probably as useful as a Hello, world!. ?php function DoSomethingOrExit($test) { if($test == 1) { exit; } return; } DoSomethingOrExit(0); echo Hello;
Re: [PHP] Probem with go-pear.bat
On Sun, Mar 13, 2011 at 5:49 PM, Alejandro Crosa alec...@ymail.com wrote: Hi...I try install pear by executing the go-pear.bat file, but I get a follow message: The go.pear.phar.dll is not a image valid of windows. Please, any help is important for me. Thanks. Alejandro See http://pear.php.net/manual/en/installation.getting.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Handling exit in eval
Is there any way to emulate an exit in eval without exiting the calling script. ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; eval($s); echo Never comes here; ? I would like to do something like this: ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; function MakeItStop() { // Do something to make the eval stop // without halting the script } $s = str_replace('exit;', 'MakeItStop();', $s); eval($s); echo Never comes here; ? A simple return would fix it IF the return isn't located within a function. Any good suggestions? Thanks in advanced Thomas Björk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Handling exit in eval
Is there any way to emulate an exit in eval without exiting the calling script. ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; eval($s); echo Never comes here; ? I would like to do something like this: ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; function MakeItStop() { // Do something to make the eval stop // without halting the script } $s = str_replace('exit;', 'MakeItStop();', $s); eval($s); echo Never comes here; ? A simple return would fix it IF the return isn't located within a function. Any good suggestions? Thanks in advanced Thomas Björk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Handling exit in eval
2011/3/14 Thomas Björk t...@bytecode.se: Is there any way to emulate an exit in eval without exiting the calling script. ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; eval($s); echo Never comes here; ? I would like to do something like this: ?php $s = 'echo Shows; exit; echo Doesn\'t show; '; function MakeItStop() { // Do something to make the eval stop // without halting the script } $s = str_replace('exit;', 'MakeItStop();', $s); eval($s); echo Never comes here; ? A simple return would fix it IF the return isn't located within a function. Any good suggestions? Thanks in advanced Thomas Björk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Can you provide a more realistic example? Just don't code anything after the last line of code that contains the exit? Surely. http://uk.php.net/manual/en/function.eval.php does say that ... A return statement will immediately terminate the evaluation of the string . So, there's your answer I suppose. Replace exit with return. -- 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] Handling exit in eval
2011/3/14 Richard Quadling rquadl...@gmail.com: And where is my UNDO button. Essentially, having exit in the eval code is no different to having it in non-eval code. eval isn't a separate entity which can be terminated. So, code the eval code differently. If you can provide some examples, maybe we can come up with a better solution. -- 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] Handling exit in eval
Richard Quadling wrote: 2011/3/14 Richard Quadling rquadl...@gmail.com: And where is my UNDO button. Essentially, having exit in the eval code is no different to having it in non-eval code. eval isn't a separate entity which can be terminated. So, code the eval code differently. If you can provide some examples, maybe we can come up with a better solution. I'm developing a kind of sandbox where you will be able to run a script without affecting your current context. The script is loaded and parsed which gives me the opportunity to allow or deny functions and classes used in the script. The only problem I have so far is the exit function which, it if is allowed, terminates the calling script as well as the eval'ed script. By using a return the problem is solved as long as the user doesn't write a function containing an exit. Here is a simple script thet the user might write (probably as useful as a Hello, world!. ?php function DoSomethingOrExit($test) { if($test == 1) { exit; } return; } DoSomethingOrExit(0); echo Hello; DoSomethingOrExit(1); echo , world!; exit; echo Bye; ? By replacing exit with return this code will echo Hello, world! before returning without echoing Bye. Another perfect solution would be if there was a way to trigger an error within the eval'ed script that crashes it and returns to the calling script. But then it just comes back to the entity-problem as you pointed out. /Thomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] assistance with php not running properly
Hello All, I have a problem where we tried to install mod_security for apache, failed and backed out of the install. Were not sure if that's what did it, but when we run certain php scripts they are no longer working, giving us blank screen ( web browser screen ) no errors in http error log or php error log. I would like to hire someone to fix this ASAP, but not sure what companies out there are good apache/php server support guys. This is a SERVER level issue, not a programming issue. Any suggestions appreciated. Thanks! Jack
[PHP] PHP Fatal error: Cannot redeclare class
Hi, I get the following error in my apache error log: [14-Mar-2011 14:17:27] PHP Fatal error: Cannot redeclare class I created a simplified set of php files and classes to formulate this question. I have 5 php files; 2 of which declare a class that has the same name in both. I know it would be very easy to change one of the class names, but I'm restricted because I'm working with legacy working code and an interface definition that cannot change either, here are the php files, how can I resolve this?, any help appreciated. Thanks, Brendan. ## phpFileOne.php ## ?php include_once './phpFileTwo.php'; include_once './phpFileFour.php'; $zIns = new Z(); $result = a($zIns); // class Z is defined in phpFileFour.php function a(Z $dataX) { $dataZ; $dataY = b($dataZ); // b is defined in phpFileTwo.php return $dataY; } echo 'presult: '.$result.'/p'; ? ## phpFileTwo.php ## ?php include_once './phpFileThree.php'; function b($dataW) { $dataU; $dataV = new A($dataU); // class A is defined in phpFileThree.php return $dataV-c(); } ? ## phpFileThree.php ## ?php include_once './phpFileFive.php'; // class Z is defined in phpFileFive.php class A extends Z { function __construct($dataM) { } function c() { return 'cValue'; } } ? ## phpFileFour.php ## ?php // class Z defined in interface definition - cannot change name class Z { } ? ## phpFileFive.php ## ?php // this class and class Z in phpFileFour.php have the same name! // Legacy class Z - cannot change name class Z { } ?
Re: [PHP] PHP Fatal error: Cannot redeclare class
On Mon, Mar 14, 2011 at 10:34, brendan_crow...@dellteam.com wrote: Hi, I get the following error in my apache error log: [14-Mar-2011 14:17:27] PHP Fatal error: Cannot redeclare class I created a simplified set of php files and classes to formulate this question. I have 5 php files; 2 of which declare a class that has the same name in both. I know it would be very easy to change one of the class names, but I'm restricted because I'm working with legacy working code and an interface definition that cannot change either, here are the php files, how can I resolve this?, any help appreciated. If it's legacy code and this is how it was, that means it never worked properly, because you can't redeclare classes or functions by the same name. That said, if you're restricted from changing the class names, how about wrapping the classes with a !class_exists() call? http://php.net/class_exists ## phpFileOne.php ## ?php include_once './phpFileTwo.php'; include_once './phpFileFour.php'; $zIns = new Z(); $result = a($zIns); // class Z is defined in phpFileFour.php function a(Z $dataX) { $dataZ; $dataY = b($dataZ); // b is defined in phpFileTwo.php return $dataY; } echo 'presult: '.$result.'/p'; ? ## phpFileTwo.php ## ?php include_once './phpFileThree.php'; function b($dataW) { $dataU; $dataV = new A($dataU); // class A is defined in phpFileThree.php return $dataV-c(); } ? ## phpFileThree.php ## ?php include_once './phpFileFive.php'; // class Z is defined in phpFileFive.php class A extends Z { function __construct($dataM) { } function c() { return 'cValue'; } } ? ## phpFileFour.php ## ?php // class Z defined in interface definition - cannot change name class Z { } ? ## phpFileFive.php ## ?php // this class and class Z in phpFileFour.php have the same name! // Legacy class Z - cannot change name class Z { } ? -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Fatal error: Cannot redeclare class
Thanks Louis, Worked a treat! -Original Message- From: Louis Huppenbauer [mailto:louis.huppenba...@gmail.com] Sent: 14 March 2011 15:10 To: Crowley, Brendan - Dell Team Subject: Re: [PHP] PHP Fatal error: Cannot redeclare class what about http://ch2.php.net/namespaces in php 5.3? 2011/3/14 brendan_crow...@dellteam.com: Hi, I get the following error in my apache error log: [14-Mar-2011 14:17:27] PHP Fatal error: Cannot redeclare class I created a simplified set of php files and classes to formulate this question. I have 5 php files; 2 of which declare a class that has the same name in both. I know it would be very easy to change one of the class names, but I'm restricted because I'm working with legacy working code and an interface definition that cannot change either, here are the php files, how can I resolve this?, any help appreciated. Thanks, Brendan. ## phpFileOne.php ## ?php include_once './phpFileTwo.php'; include_once './phpFileFour.php'; $zIns = new Z(); $result = a($zIns); // class Z is defined in phpFileFour.php function a(Z $dataX) { $dataZ; $dataY = b($dataZ); // b is defined in phpFileTwo.php return $dataY; } echo 'presult: '.$result.'/p'; ? ## phpFileTwo.php ## ?php include_once './phpFileThree.php'; function b($dataW) { $dataU; $dataV = new A($dataU); // class A is defined in phpFileThree.php return $dataV-c(); } ? ## phpFileThree.php ## ?php include_once './phpFileFive.php'; // class Z is defined in phpFileFive.php class A extends Z { function __construct($dataM) { } function c() { return 'cValue'; } } ? ## phpFileFour.php ## ?php // class Z defined in interface definition - cannot change name class Z { } ? ## phpFileFive.php ## ?php // this class and class Z in phpFileFour.php have the same name! // Legacy class Z - cannot change name class Z { } ?
Re: [PHP] Deleting elements from the middle of an array
On Mon, Mar 14, 2011 at 09:34:33PM +0100, Peter Lind wrote: On 14 March 2011 21:31, Paul M Foster pa...@quillandmouse.com wrote: Here's what I need to do: I have an indexed array, from which I need to delete elements in the middle. Once completed, the indexes should be numerically in sequence, as they were when I first encountered the array. That is: Before: $arr = array(0 = 5, 1 = 6, 2 = 7, 3 = 8, 4 = 9, 5 = 10); After: $arr = array(0 = 5, 1 = 6, 2 = 9, 3 = 10); I've tried: 1) Using for() with unset(). Elements are deleted, but the indexes are no longer sequential. 2) Using for() with array_splice(). Understandably, deletes certain elements but not others. 3) Using foreach() with referenced array elements. Neither unset() nor array_splice() appear to have any effect on the array at all. 4) while() loop using current() and the like. But these array functions return values, not references, so the array isn't actually modified. 5) array_walk() with unset() array_splice(). No effect on the array. Anyone know how to do this, or know of a reference on how to? Remove the elements, then use sort(). I've given a simplified example. The actual target array is multi-dimensional. Sort() won't work in a case like that, as far as I know. Moreover, I don't want the array sorted based on the element values. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Deleting elements from the middle of an array
On 14 March 2011 22:10, Paul M Foster pa...@quillandmouse.com wrote: On Mon, Mar 14, 2011 at 09:34:33PM +0100, Peter Lind wrote: On 14 March 2011 21:31, Paul M Foster pa...@quillandmouse.com wrote: Here's what I need to do: I have an indexed array, from which I need to delete elements in the middle. Once completed, the indexes should be numerically in sequence, as they were when I first encountered the array. That is: Before: $arr = array(0 = 5, 1 = 6, 2 = 7, 3 = 8, 4 = 9, 5 = 10); After: $arr = array(0 = 5, 1 = 6, 2 = 9, 3 = 10); I've tried: 1) Using for() with unset(). Elements are deleted, but the indexes are no longer sequential. 2) Using for() with array_splice(). Understandably, deletes certain elements but not others. 3) Using foreach() with referenced array elements. Neither unset() nor array_splice() appear to have any effect on the array at all. 4) while() loop using current() and the like. But these array functions return values, not references, so the array isn't actually modified. 5) array_walk() with unset() array_splice(). No effect on the array. Anyone know how to do this, or know of a reference on how to? Remove the elements, then use sort(). I've given a simplified example. The actual target array is multi-dimensional. Sort() won't work in a case like that, as far as I know. Moreover, I don't want the array sorted based on the element values. Ahh, I see - you wanted me to guess at the actual circumstances of the case instead of provide an answer to the example you posted. My bad. -- hype WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 /hype -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Deleting elements from the middle of an array
I've given a simplified example. The actual target array is multi-dimensional. Your questioni sn't entirely clear but there's lot of chatter about multidimensional arrays on the array_values() page that might provide a solution. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php or juvascript convert IETF format to ISO08601
Hello Evrybody, Can i convert IETF format (ex: Wed, 18 Oct 2009 13:00:00 EST) in ISO8601 format (ex: 2009-11-05T13:15:30Z) Does somebody know some php scripte or similar? Thanks... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php or juvascript convert IETF format to ISO08601
On 15/03/2011, at 12:32 PM, Jordan wrote: Hello Evrybody, Can i convert IETF format (ex: Wed, 18 Oct 2009 13:00:00 EST) in ISO8601 format (ex: 2009-11-05T13:15:30Z) Does somebody know some php scripte or similar? Thanks... strtotime() (http://php.net/strtotime) and date() (http://php.net/date). There's even a DATE_ISO8601 constant for the correct date format. --- 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] Handling exit in eval
Richard Quadling wrote: On 14 March 2011 12:14, DELiTH t...@bytecode.se wrote: Richard Quadling wrote: 2011/3/14 Richard Quadling rquadl...@gmail.com: And where is my UNDO button. Essentially, having exit in the eval code is no different to having it in non-eval code. eval isn't a separate entity which can be terminated. So, code the eval code differently. If you can provide some examples, maybe we can come up with a better solution. I'm developing a kind of sandbox where you will be able to run a script without affecting your current context. The script is loaded and parsed which gives me the opportunity to allow or deny functions and classes used in the script. The only problem I have so far is the exit function which, it if is allowed, terminates the calling script as well as the eval'ed script. By using a return the problem is solved as long as the user doesn't write a function containing an exit. Here is a simple script thet the user might write (probably as useful as a Hello, world!. ?php function DoSomethingOrExit($test) { if($test == 1) { exit; } return; } DoSomethingOrExit(0); echo Hello; DoSomethingOrExit(1); echo , world!; exit; echo Bye; ? By replacing exit with return this code will echo Hello, world! before returning without echoing Bye. Another perfect solution would be if there was a way to trigger an error within the eval'ed script that crashes it and returns to the calling script. But then it just comes back to the entity-problem as you pointed out. /Thomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Why not just invoke a separate instance of PHP using exec() ? Or take a look at runkit/runkit_Sandbox : http://uk.php.net/manual/en/book.runkit.php exec() tends to allocate to much resources and Runkit_Sandbox is what I'm trying to get away from =) The Runkit_Sandbox requires that the server is configured to use it and my intended solution will run on almost any server without any spcial needs. (exec is also restricted from many hosting server which makes it a poor choise.) My little SandBox will run on almost any server and doesn't require any special configuration. Sure, it will suck on resources but it will work as an alternative =) /Thomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] help with a safe mode snag
Hello All, Im writing a script that creates a temp file which it then encrypts and sends out in an email. This works 100% on servers that don't have safe mode, but this server with safe mode doesn't understand it's all the same user. Error: Mon Mar 14 21:10:11 2011] [error] [client 14.18.8.43] PHP Warning: fopen() [a href='function.fopen'function.fopen/a]: SAFE MODE Restriction in effect. The script whose uid is 50069 is not allowed to access /tmp/A1_mYM5q5 owned by uid 48 in Any suggestions? Thanks!
Re: [PHP] Deleting elements from the middle of an array
how about creating two arrays, one empty one. pop the elements you want out of the first array and push them to the second. skip the push on the elements you don't want in the second array? Just a thought. --curtis Paul M Foster wrote: On Mon, Mar 14, 2011 at 09:34:33PM +0100, Peter Lind wrote: On 14 March 2011 21:31, Paul M Foster pa...@quillandmouse.com wrote: Here's what I need to do: I have an indexed array, from which I need to delete elements in the middle. Once completed, the indexes should be numerically in sequence, as they were when I first encountered the array. That is: Before: $arr = array(0 = 5, 1 = 6, 2 = 7, 3 = 8, 4 = 9, 5 = 10); After: $arr = array(0 = 5, 1 = 6, 2 = 9, 3 = 10); I've tried: 1) Using for() with unset(). Elements are deleted, but the indexes are no longer sequential. 2) Using for() with array_splice(). Understandably, deletes certain elements but not others. 3) Using foreach() with referenced array elements. Neither unset() nor array_splice() appear to have any effect on the array at all. 4) while() loop using current() and the like. But these array functions return values, not references, so the array isn't actually modified. 5) array_walk() with unset() array_splice(). No effect on the array. Anyone know how to do this, or know of a reference on how to? Remove the elements, then use sort(). I've given a simplified example. The actual target array is multi-dimensional. Sort() won't work in a case like that, as far as I know. Moreover, I don't want the array sorted based on the element values. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Failure in bitwise operations moving from 5.2.x to 5.3.x
Greetings, I'm moving some scripts from an older server (SuSE who-knows-what, running PHP 5.2.5) to a newer one (Ubuntu 10.10, running PHP 5.3.2). For the most part there haven't been any problems, or they've been things that I was able to fix easily. This one's got me stumped. I have the following line in a script: $this-bc = ($this-network | (~$this-netmask)) 4294967295; $this-network and $this-netmask should both be of type long, and I should wind up with another long. I didn't write the original method, and I can't remember what bc stands for at the moment, but it's part of a tool for working out first and last IP address, netmask, and a few other things from a subnet definition. On the old system, it works fine. On the new system, I get the following error: PHP Fatal error: Unsupported operand types in /var/www/test/common_subnet.inc on line 39 I've done a little searching without any luck: if anyone can give me a quick answer, or at least point me to something that will explain what's going on, I'd appreciate it. Thanks, Alex McKenzie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Deleting elements from the middle of an array
On Mon, Mar 14, 2011 at 10:14:53PM +0100, Peter Lind wrote: On 14 March 2011 22:10, Paul M Foster pa...@quillandmouse.com wrote: [snip] Remove the elements, then use sort(). I've given a simplified example. The actual target array is multi-dimensional. Sort() won't work in a case like that, as far as I know. Moreover, I don't want the array sorted based on the element values. Ahh, I see - you wanted me to guess at the actual circumstances of the case instead of provide an answer to the example you posted. My bad. Is the sarcasm really necessary? Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Failure in bitwise operations moving from 5.2.x to 5.3.x
This one's got me stumped. I have the following line in a script: $this-bc = ($this-network | (~$this-netmask)) 4294967295; $this-network and $this-netmask should both be of type long, and I should wind up with another long. I didn't write the original method, and I can't remember what bc stands for at the moment, but it's part of a tool for working out first and last IP address, netmask, and a few other things from a subnet definition. On the old system, it works fine. On the new system, I get the following error: PHP Fatal error: Unsupported operand types in /var/www/test/common_subnet.inc on line 39 Have you checked the types being operated on? I'm wondering if somehow one of the object properties you're operating on has changed has changed in terms of type. I'd try var_dumping each of the properties ($this-network and $this-netmask) the line above just to make sure they didn't somehow get switched to a type that bitwise operators complain about (array, Object.) Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com
[PHP] problem with if and exact match
I want to be able to match if a string is contained within the string I am evaluating. I know that if ( $name == xxjacksonxx); based on the below would be true. But I want to be able to say if jackson is contained within $name that it's a match. I tried the below without success.. Not getting the operand properly.. ? $name = xxjacksonxx; if ( preg_match($name, jackson)) { print true; } else { print false; } ? Thanks! Jack
Re: [PHP] problem with if and exact match
Try If(preg_match(/Jackson/i, $name)) {echo 'match'; }else{ echo 'fail'; } Richard Buskirk Sent from my iPhone On Mar 15, 2011, at 1:02 AM, Jack jacklistm...@gmail.com wrote: I want to be able to match if a string is contained within the string I am evaluating. I know that if ( $name == xxjacksonxx); based on the below would be true. But I want to be able to say if jackson is contained within $name that it's a match. I tried the below without success.. Not getting the operand properly.. ? $name = xxjacksonxx; if ( preg_match($name, jackson)) { print true; } else { print false; } ? Thanks! Jack -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with if and exact match
On 15/03/2011, at 6:02 PM, Jack wrote: I want to be able to match if a string is contained within the string I am evaluating. I know that if ( $name == xxjacksonxx); based on the below would be true. But I want to be able to say if jackson is contained within $name that it's a match. I tried the below without success.. Not getting the operand properly.. ? $name = xxjacksonxx; if ( preg_match($name, jackson)) { print true; } else { print false; } ? Thanks! Jack if(strpos($name, 'jackson') !== false) { true } You can use stripos for case-insentive matching. Using regex functions when you don't need the power is overkill and slower. Your call to preg_match wasn't working because you need your search term first, and it needs proper delimiters. --- 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] problem with if and exact match
Thanks everyone... great examples...works ( both methods ) Thanks! Jack -Original Message- From: Alexis Antonakis [mailto:ad...@antonakis.co.uk] Sent: Tuesday, March 15, 2011 1:10 AM To: Jack Subject: Re: [PHP] problem with if and exact match http://php.net/manual/en/function.preg-match.php On 14/03/11 23:02, Jack wrote: I want to be able to match if a string is contained within the string I am evaluating. I know that if ( $name == xxjacksonxx); based on the below would be true. But I want to be able to say if jackson is contained within $name that it's a match. I tried the below without success.. Not getting the operand properly.. ? $name = xxjacksonxx; if ( preg_match($name, jackson)) { print true; } else { print false; } ? Thanks! Jack -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php