php-general Digest 30 Oct 2007 12:28:31 -0000 Issue 5100

Topics (messages 263794 through 263808):

Re: moving over to php 5
        263794 by: Larry Garfield
        263800 by: Per Jessen
        263801 by: Per Jessen

Configuring 5.2.4 for Mac OSX and Webstar
        263795 by: Steve Meredith

Re: Newline
        263796 by: Crayon Shin Chan
        263797 by: Nathan Nobbe

Re: unexpected '@' in preg_replace???
        263798 by: Zoltán Németh

Re: unexpected '@' in preg_replace??? - SOLVED
        263799 by: Zoltán Németh

isodd() php5?
        263802 by: Hulf
        263803 by: Jason

PHP installation
        263804 by: Richard Heyes
        263805 by: Per Jessen
        263807 by: Richard Heyes
        263808 by: Richard Heyes

REGEX: grouping of alternative patterns
        263806 by: Stijn Verholen

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
On Monday 29 October 2007, Philip Thompson wrote:

>  I think the real question is.... will listservs (like this one) stop
> supporting people running applications on PHP4 in 98 days (
> http://gophp5.org/)? I'm not saying we should outcast *those people* who
> haven't transitioned, but will the process speed up if a community puts
> their foot down? Is this how it will be..................
>
> [example question]
> I'm running PHP4 and blah blah blah...
>
> [example response]
> Oh, I noticed you said PHP4. Sorry, upgrade, then we'll support...
>
> Just a thought...
> ~Philip

Did you see the mega thread that started from someone asking about PHP 4 
classes? :-)

Personally I've already written off PHP 4 support, and assume that people have 
PHP 5.  I have access to only one box that is older than PHP 5.2.0, and 
that's a 5.1.6 box.  

Here's a bigger question: When will people stop using mysql_ as their example 
API, when PDO is more standard in PHP 5 and more secure, and mysqli is 
available as well?

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message ---
Larry Garfield wrote:

> Here's a bigger question: When will people stop using mysql_ as their
> example API, when PDO is more standard in PHP 5 and more secure, and
> mysqli is available as well?

As always, the key question must be - what's the advantage of moving? 
When the developer benefits from something being "more standard" and
more secure, then he'll change.  
If you want to force someone to change, you remove the interface (after
having marked it deprecated for a while). 


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
Larry Garfield wrote:

> On Monday 29 October 2007, Per Jessen wrote:
>> Cristian Vrabie wrote:
>> > Hmm 117,223 hosts with php4 only support. Did you actually checked
>> > how many have php5 support? Many more.
>>
>> There are 178.112 hosters that have PHP5 support.  I checked.
> 
> Where and how did you check?  

Well, I didn't.  I just provided a silly answer to an impossible
question.  There is no way anyone could possibly come up with a
remotely accurate number of how many hosters have this or that.  So I
made the numbers up.  $RANDOM.

> I have a hard time believing that there are 300,000 different
> commercial web hosting companies out there.  That many servers, sure,
> but companies? 

300,000 is probably a lot, yes. Still, Switzerland alone has roughly
335.000 companies.  About 400 of those are members of a Swiss
association for ISPs, but there's probably another couple of hundred
that aren't.  Extrapolating from e.g. 500 webhosters for a population
of 7million, that would make roughly 35,000 in the EU (pop. 480mill). 


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
I'm having difficulty compiling and upgrading to version 5.2.4. Also using
WebSTAR.
Here's the steps I took and the resulting errors.

Any help would be appreciated!

1. Download the latest copy of PHP source code from [ http://www.php.net/
]http://www.php.net 
2. Open the Terminal application (in Applications/Utilities).
3. Type in "cd " and then drag the PHP source folder from the Finder to the
Terminal.
4. Click back in the Terminal and hit return. This should put you in the PHP
source folder.
5. Type in "./configure" and hit return. If you get a "command unknown"
error, type in "sudo chmod a+rx configure" and retry. Wait for the script to
complete.
6. Type in "make" and hit return/enter. Wait for the compile to complete.

Results, no compiled php to copy to!

Last login: Sat Oct 20 15:58:53 on console
Welcome to Darwin!
steve-merediths-powerbook-g4-17:~ stevemeredith$ cd
/Users/stevemeredith/Desktop/php-5.2.4/ 
steve-merediths-powerbook-g4-17:~/Desktop/php-5.2.4 stevemeredith$ ./configure
creating cache ./config.cache
checking for Cygwin environment... no
checking for mingw32 environment... no
checking for egrep... grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking host system type... powerpc-apple-darwin8.10.0
checking target system type... powerpc-apple-darwin8.10.0
checking for gcc... no
checking for cc... no
configure: error: no acceptable cc found in $PATH
steve-merediths-powerbook-g4-17:~/Desktop/php-5.2.4 stevemeredith$ make
-bash: make: command not found
steve-merediths-powerbook-g4-17:~/Desktop/php-5.2.4 stevemeredith$ 







Steve Meredith
Internet Services Bureau Chief
Montana Office of Public Instruction
www.opi.mt.gov
www.metnet.mt.gov
MathScience.mt.gov
406-444-3563


--- End Message ---
--- Begin Message ---
On Monday 29 October 2007, Nathan Nobbe wrote:
> if you were going to do that you may as well use PHP_EOL
> its cross-platform and doesnt require an define directive.
> (php5 only)

It's available in 4.3.10 as well, but manual doesn't specify what it 
defines - I suppose I can echo or vardump it to find out. Also manual 
doesn't mention "cross-platform", in any case even if it 
is "cross-platform" it seems pointless because how does PHP know which 
environment the output is going to be used in? I 
define 'CR', 'LF', 'CRLF' and use them as circumstances dictate.

-- 
Crayon

--- End Message ---
--- Begin Message ---
On 10/30/07, Crayon Shin Chan <[EMAIL PROTECTED]> wrote:
>
> On Monday 29 October 2007, Nathan Nobbe wrote:
> > if you were going to do that you may as well use PHP_EOL
> > its cross-platform and doesnt require an define directive.
> > (php5 only)
>
> It's available in 4.3.10 as well,


youre right about that; my mistake.

but manual doesn't specify what it
> defines -


let the source tell it:
phpunpack/php5.2-200708051230/NEWS:2867:- Added PHP_EOL constant that
contains the OS way of representing newlines.

 47 #ifdef PHP_WIN32
 48 #include "tsrm_win32.h"
 49 #include "win95nt.h"
 50 #   ifdef PHP_EXPORTS
 51 #   define PHPAPI __declspec(dllexport)
 52 #   else
 53 #   define PHPAPI __declspec(dllimport)
 54 #   endif
 55 #define PHP_DIR_SEPARATOR '\\'
 56 #define PHP_EOL "\r\n"
 57 #else
 58 #define PHPAPI
 59 #define THREAD_LS
 60 #define PHP_DIR_SEPARATOR '/'
 61 #if defined(__MacOSX__)
 62 #define PHP_EOL "\r"
 63 #else
 64 #define PHP_EOL "\n"
 65 #endif
 66 #endif

I suppose I can echo or vardump it to find out.


a little trickier than you might guess :

php > var_dump(PHP_EOL);
string(1) "
"

Also manual
> doesn't mention "cross-platform", in any case even if it
> is "cross-platform" it seems pointless because how does PHP know which
> environment the output is going to be used in?


its supposed to be used for the command line;
theoretically the output will land on the same system from which its
generated.
however, coming from my linux box; this was correctly interpreted by
internet explorer
<?php
echo 'blah' . PHP_EOL . 'blah';
?>
result when viewing source was
blah
blah

I define 'CR', 'LF', 'CRLF' and use them as circumstances dictate.


the use of that definitely depends upon the circumstances; ill stick w/ the
predefined constant until i run into a problem ;)

-nathan

--- End Message ---
--- Begin Message ---
2007. 10. 29, hétfő keltezéssel 11.17-kor Daniel Brown ezt írta:
> On 10/29/07, Zoltán Németh <[EMAIL PROTECTED]> wrote:
> > hi list,
> >
> > I have this code:
> [snip!]
> > Parse error: syntax error, unexpected '@'
> > in /home/znemeth/public_html/test/pregreplacetest1.php(94) : regexp code
> > on line 1
> >
> > Fatal error: preg_replace() [<a
> > href='function.preg-replace'>function.preg-replace</a>]: Failed
> > evaluating code: [EMAIL PROTECTED]
> > in /home/znemeth/public_html/test/pregreplacetest1.php on line 94
> [snip=again!]
> 
>     Zoltan,
> 
>     If you're using preg_replace(), where are your start and stop
> characters for the pattern and subject?
> 
>     $szoveg = preg_replace('/'.$mit.'/','/'.$mire.'/',$dokumentum);

$mit and $mire are arrays. $mit contains all the patterns, they all
start and end with /
$mire contains all the replacements.

> 
>     You could otherwise try ereg_replace(); without the slashes, or do
> an htmlentities($dokumentum);.

ereg_replace cannot take arrays as arguments...
htmlentities might work but then all my patterns containing < or > has
to be modified - and then it might replace strings which I don't want to
get replaced. e.g. &lt;script&gt; might be a legal string which I don't
want to replace, but I want to replace <script>

greets
Zoltán Németh

> 
> -- 
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
> 
> Give a man a fish, he'll eat for a day.  Then you'll find out he was
> allergic and is hospitalized.  See?  No good deed goes unpunished....
> 

--- End Message ---
--- Begin Message ---
2007. 10. 29, hétfő keltezéssel 09.17-kor Jim Lucas ezt írta:
> Daniel Brown wrote:
> > On 10/29/07, Zoltán Németh <[EMAIL PROTECTED]> wrote:
> >> hi list,
> >>
> >> I have this code:
> > [snip!]
> >> Parse error: syntax error, unexpected '@'
> >> in /home/znemeth/public_html/test/pregreplacetest1.php(94) : regexp code
> >> on line 1
> >>
> >> Fatal error: preg_replace() [<a
> >> href='function.preg-replace'>function.preg-replace</a>]: Failed
> >> evaluating code: [EMAIL PROTECTED]
> >> in /home/znemeth/public_html/test/pregreplacetest1.php on line 94
> > [snip=again!]
> > 
> >     Zoltan,
> > 
> >     If you're using preg_replace(), where are your start and stop
> > characters for the pattern and subject?
> > 
> >     $szoveg = preg_replace('/'.$mit.'/','/'.$mire.'/',$dokumentum);
> > 
> >     You could otherwise try ereg_replace(); without the slashes, or do
> > an htmlentities($dokumentum);.
> > 
> 
> Look again and you will notice that $mit and $mire are both arrays.
> 
> Also, the starting and stopping points are in the $mit array elements.
> 
> The starting and stopping points are not allowed in the $mire array.
> 
> This was the offending line in the code.  I removed the e from the modifiers 
> list and it started 
> working.  See if you can run the code without it.
> 
>           '/<strong[^>]*>(.*?)<\/strong>/i',      // <strong>

many thanks Jim, it solved the issue

> 
> 
> you missed your closing option
>           '/<\/?p[^>]*>/i',                           // <P>
> 
> or maybe you should have a different entry to remove the </p> and replace it 
> with nothing.
> this
>           '/<p[^>]*>/i',                           // <P>
> that
>        "\n\n\t",
> 
> this
>           '/<\/p[^>]*>/i',                           // </P>
> that
>        '',

thanks for this also, I added it

> 
> Side note, you might want to look into using the '+' instead of the '*'.
>       '+' = must be one or more
>       '*' = 0 or more
> 
> In some of the cases here, I see where this can bite you in the butt later.
> 

thanks for the tip, I will look at it

greets
Zoltán Németh

> 
> -- 
> Jim Lucas
> 
>     "Some men are born to greatness, some achieve greatness,
>         and some have greatness thrust upon them."
> 
> Twelfth Night, Act II, Scene V
>      by William Shakespeare
> 

--- End Message ---
--- Begin Message ---
Hi,

Is there a built in function in PHP5 to determine if an integer is even or 
odd?


Ross 

--- End Message ---
--- Begin Message ---
At 09:32 30/10/2007, Hulf wrote:
Hi,

Is there a built in function in PHP5 to determine if an integer is even or
odd?

How about :

if ($IntegerValue % 2) {
        // odd
} else {
        // even
}

HTH
J
--- End Message ---
--- Begin Message ---
Hi,

Trying to install PHP, however it's failing with the following:

Configuring extensions
checking whether to enable LIBXML support... yes
checking libxml2 install dir... /usr/lib64
checking for xml2-config path... /usr/bin/xml2-config
checking whether libxml build works... no
configure: error: build test failed. Please check the config.log for details.


The following is in config.log:

configure:20028: checking whether libxml build works
configure:20055: gcc -o conftest -g -O2   conftest.c

         -lresolv -lm -ldl -lnsl  -lxml2 -lz -lm 1>&5
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
configure: failed program was:
#line 20044 "configure"
#include "confdefs.h"


    char xmlInitParser();
    int main() {
      xmlInitParser();
      return 0;
    }



If it helps, this is a bit of an `ls -l` of /usr/lib64:

libxml2.so -> libxml2.so.2.6.27
libxml2.so.2 -> libxml2.so.2.6.27
libxml2.so.2.6.19
libxml2.so.2.6.27

And this is what's at the end of my config.log:

configure:19793: checking whether to enable LIBXML support
configure:19841: checking libxml2 install dir
configure:19870: checking for xml2-config path
configure:20028: checking whether libxml build works
configure:20055: gcc -o conftest -g -O2   conftest.c

         -lresolv -lm -ldl -lnsl  -lxml2 -lz -lm 1>&5
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
configure: failed program was:
#line 20044 "configure"
#include "confdefs.h"


    char xmlInitParser();
    int main() {
      xmlInitParser();
      return 0;
    }


Thanks.


--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

--- End Message ---
--- Begin Message ---
Richard Heyes wrote:

> The following is in config.log:
> 
> configure:20028: checking whether libxml build works
> configure:20055: gcc -o conftest -g -O2   conftest.c
> 
>           -lresolv -lm -ldl -lnsl  -lxml2 -lz -lm 1>&5
> /usr/bin/ld: cannot find -lz

Looks like you need to install libz. 


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
Per Jessen wrote:
Richard Heyes wrote:

The following is in config.log:

configure:20028: checking whether libxml build works
configure:20055: gcc -o conftest -g -O2   conftest.c

          -lresolv -lm -ldl -lnsl  -lxml2 -lz -lm 1>&5
/usr/bin/ld: cannot find -lz

Looks like you need to install libz.

I installed various zlib and zlib-devel packages, but finally went with an rpm, but when I run `apachectl configtest` I get this:

Cannot load /usr/lib64/httpd/modules/libphp5.so into server: /usr/lib64/httpd/modules/libphp5.so: undefined symbol: apr_pool_cleanup_null

Umm help?

--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
Per Jessen wrote:
Richard Heyes wrote:

The following is in config.log:

configure:20028: checking whether libxml build works
configure:20055: gcc -o conftest -g -O2   conftest.c

          -lresolv -lm -ldl -lnsl  -lxml2 -lz -lm 1>&5
/usr/bin/ld: cannot find -lz

Looks like you need to install libz.

I installed various zlib and zlib-devel packages, but finally went with an rpm, but when I run `apachectl configtest` I get this:

Cannot load /usr/lib64/httpd/modules/libphp5.so into server: /usr/lib64/httpd/modules/libphp5.so: undefined symbol: apr_pool_cleanup_null

OK so now I'm back to compiling PHP after the ridiculous nightmare of rpms. I checked /lib and have the following:

[EMAIL PROTECTED] php-5.2.4]# ls -l /lib/libz.so.1.2.3
-rwxr-xr-x 1 root root 71744 Sep 21 19:23 /lib/libz.so.1.2.3

Is PHP looking for a different file?

Thanks.

--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

--- End Message ---
--- Begin Message ---
Hey list,

I'm having problems with grouped alternative patterns.
The regex I would like to use, is the following:

/\s*(`?.+`?)\s*int\s*(\(([0-9]+)\))?\s*(unsigned)?\s*(((auto_increment)?\s*(primary\s*key)?)|((not\s*null)?\s*(default\s*(`.*`|[0-9]*)?)?))\s*/i

It matches this statement:

`id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY

But not this:

`test4` INT(11) UNSIGNED NOT NULL DEFAULT 5

However, if I switch the alternatives, the first statement doesn't match, but the second does.
FYI: In both cases, the column name and data type are matched, as expected.
It appears to be doing lazy evaluation on the pattern, even though every resource I can find states that every alternative is tried in turn until a match is found.

Any ideas on how this can be resolved would be greatly appreciated.

Here is some code:

<?php
$pattern1 = '/\s*(`?.+`?)\s*int\s*(\(([0-9]+)\))?\s*(unsigned)?\s*(((auto_increment)?\s*(primary\s*key)?)|((not\s*null)?\s*(default\s*(`.*`|[0-9]*)?)?))\s*/i'; $pattern2 = '/\s*(`?.+`?)\s*int\s*(\(([0-9]+)\))?\s*(unsigned)?\s*(((not\s*null)?\s*(default\s*(`.*`|[0-9]*)?)?)|((auto_increment)?\s*(primary\s*key)?))\s*/i';
$column1 = '`id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY';
$column2 = '`test4` INT(11) UNSIGNED NOT NULL DEFAULT 5';
$matches = array();

preg_match($pattern1, $column1, $matches); print_r($matches); // match
preg_match($pattern1, $column2, $matches); print_r($matches); // doesn't match

preg_match($pattern2, $column1, $matches); print_r($matches); // doesn't match
preg_match($pattern2, $column2, $matches); print_r($matches); // match
?>


Greetz,

Stijn

--- End Message ---

Reply via email to