php-general Digest 24 Jun 2007 22:04:59 -0000 Issue 4867

Topics (messages 257722 through 257735):

Re: Strange Fatal Error Possibly Memory
        257722 by: ecc

Re: foreach() using current() strange beahvior
        257723 by: Julien Pauli

PHP not posting
        257724 by: Pieter du Toit
        257725 by: Stut
        257726 by: Pieter du Toit
        257727 by: Tijnema
        257728 by: Mark Kelly
        257729 by: Pieter du Toit
        257731 by: Tijnema
        257732 by: Tijnema

PHP, mbstring, UTF-8 and indexing strings
        257730 by: delsvr

UI toolkit
        257733 by: Darren Whitlen

Re: file_get_contents crash, if file is bigger than memory_limit
        257734 by: Jochem Maas

Display paragraphs from a mysql db
        257735 by: nitrox .

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 ---
Maybe this is an error/exception in the exception handeler... :-) Sometimes
we had this error in these cases!
-- 
View this message in context: 
http://www.nabble.com/Strange-Fatal-Error-Possibly-Memory-tf3960349.html#a11273616
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message ---
Don't worry I know how variable work internaly into Zend Engine ( for those
who want more info, Derick Rethan's got a good pdf file explaining that
process here :
http://derickrethans.nl/files/phparch-php-variables-article.pdf , Derick, if
you here us, feel free to come in that conversation ;-) )

But as said, that is an internal PHP behavior that, in my opinion, should be
explained in the documentation.
Now consider this :

<?php
$a = array("One","Two","Three");
$b = $a;

next($b); // go to the second key of $b

foreach ($a AS $k=>$v) {

   if (current($a) == current($b)){ // I want you to stop on the second key
of $b
       var_dump(current($b)); // will never get echoed, as current($a)
always returns String"One"
       break;
   }

}
?>

Due to COW, using current($a) makes PHP making a "real" copy of $a array to
work on it, and current($a) is always at its first place ( String"One")
because PHP works on the "real" copy, and its own array iterator. In that
example, the if condition will never be satisfied.
Ok let's make it funnier now :

<?php
$a = array("One","Two","Three");
$b = $a;
$c = &$a;

next($b);

foreach ($a AS $k=>$v) {

   if (current($a) == current($b)){
       var_dump(current($b)); // works : outputs String"Two"
       break;
   }

}

var_dump(current($a)); // output String"Two"
?>

Aha, now if I hold a reference to $a variable ($c here ), it looks like COW
doesn't show the same behavior as before.
Foreach seems to keep working on a "lazy" copy of $a, and so it moves the
real $a internal iterator as shown here. The if condition is verified and
the last script line clearly shows that $a internal pointer has been
manipulated by the foreach loop.


We see here that working on internal iterators using foreach is not really
recommanded. I have never needed to do that in a real developpement as well,
I'm just experimenting PHP behavior, but I think that the official
documentation should warn users about such behaviors.

For information : it's actually tested, for me, on PHP 5.2.3 running on a
Windows server. Error Reporting is set to E_ALL.

cheers.
Julien (French)

2007/6/23, Nathan Nobbe <[EMAIL PROTECTED]>:

> On 6/23/07, Robert Cummings < [EMAIL PROTECTED]> wrote:
> Regardless of additional documentation or not, I think it's rather poor
> choice of programming style to mix the foreach construct with the older,
> lower level, internal array manipulation and probing functions. I think
> that is what should be documented since you just might get weird
> results :)

i agree; at least i have never had a need to determine the current index
of the internal array pointer in nearly 3 years working w/ php.
although it is somewhat interesting to experiment w/ the language to see
how it behaves :)

-nathan


On 6/23/07, Robert Cummings < [EMAIL PROTECTED]> wrote:
>
> On Sat, 2007-06-23 at 15:15 -0400, Nathan Nobbe wrote:
> >
> > in summary, COW or not; i think the documentation could be revised a
> bit to
> > clarify these subtleties.
>
> Regardless of additional documentation or not, I think it's rather poor
> choice of programming style to mix the foreach construct with the older,
> lower level, internal array manipulation and probing functions. I think
> that is what should be documented since you just might get weird
> results :)
>
> Cheers,
> Rob.
> --
> .------------------------------------------------------------.
> | InterJinn Application Framework - http://www.interjinn.com |
> :------------------------------------------------------------:
> | An application and templating framework for PHP. Boasting  |
> | a powerful, scalable system for accessing system services  |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for       |
> | creating re-usable components quickly and easily.          |
> `------------------------------------------------------------'
>
>


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

I installed PHP5 on iis and i can see "hello world" and phpinfo.

When i right click the webpage and view source, i can see the php code, and 
the form does not want to post the form details.

Will appreciate any help. 

--- End Message ---
--- Begin Message ---
Pieter du Toit wrote:
I installed PHP5 on iis and i can see "hello world" and phpinfo.

When i right click the webpage and view source, i can see the php code, and the form does not want to post the form details.

Will appreciate any help.

My amazing psychic abilities tell me that...

...you need to show us your code before we can have any chance of helping.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
Nothing major here is the code:

<?

if ($_POST['name']) {

echo "name posted";

}

?>

<html>

<head>

<title></title>

</head>

<body>

<form action="1.php" method="post">

Name:<input type="text" name="name">

<input type="submit" value="submit">

</form>

</body>

</html>

"Stut" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Pieter du Toit wrote:
>> I installed PHP5 on iis and i can see "hello world" and phpinfo.
>>
>> When i right click the webpage and view source, i can see the php code, 
>> and the form does not want to post the form details.
>>
>> Will appreciate any help.
>
> My amazing psychic abilities tell me that...
>
> ...you need to show us your code before we can have any chance of helping.
>
> -Stut
>
> -- 
> http://stut.net/ 

--- End Message ---
--- Begin Message ---
On 6/24/07, Pieter du Toit <[EMAIL PROTECTED]> wrote:
Nothing major here is the code:

<?
  ^^ Do you have short tags enabled?, try <?php

if ($_POST['name']) {

Not the right way to check, you should use:
if(isset($_POST['name']) {


echo "name posted";

}

?>
<html code>

If that still doesn't work, try a var_dump($_POST) at top of your
script, and see if there's anything inside.

Tijnema


"Stut" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Pieter du Toit wrote:
>> I installed PHP5 on iis and i can see "hello world" and phpinfo.
>>
>> When i right click the webpage and view source, i can see the php code,
>> and the form does not want to post the form details.
>>
>> Will appreciate any help.
>
> My amazing psychic abilities tell me that...
>
> ...you need to show us your code before we can have any chance of helping.
>
> -Stut
>
> --
> http://stut.net/

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




--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

--- End Message ---
--- Begin Message ---
On Sunday 24 June 2007 13:54, Pieter du Toit wrote:
> Hi
>
> I installed PHP5 on iis and i can see "hello world" and phpinfo.
>
> When i right click the webpage and view source, i can see the php code,
> and the form does not want to post the form details.
>
> Will appreciate any help.

I'm not really knowledgeable about IIS, but if you can see php code in the 
browser it usually means the web server hasn't been set up to execute php 
rather than just serving it. 

Check your config to make sure it knows to pass *.php requests through php5 
rather than just sending the page back directly. How you do this on IIS is 
beyond me I'm afraid.

HTH

--- End Message ---
--- Begin Message ---
But why is the php code showing just like my code at the top when i right 
click the webpage and view source, i suspect this must be a php.ini setting 
or sonmething
"Tijnema" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 6/24/07, Pieter du Toit <[EMAIL PROTECTED]> wrote:
>> Nothing major here is the code:
>>
>> <?
>   ^^ Do you have short tags enabled?, try <?php
>
>> if ($_POST['name']) {
>
> Not the right way to check, you should use:
> if(isset($_POST['name']) {
>
>>
>> echo "name posted";
>>
>> }
>>
>> ?>
> <html code>
>
> If that still doesn't work, try a var_dump($_POST) at top of your
> script, and see if there's anything inside.
>
> Tijnema
>
>>
>> "Stut" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>> > Pieter du Toit wrote:
>> >> I installed PHP5 on iis and i can see "hello world" and phpinfo.
>> >>
>> >> When i right click the webpage and view source, i can see the php 
>> >> code,
>> >> and the form does not want to post the form details.
>> >>
>> >> Will appreciate any help.
>> >
>> > My amazing psychic abilities tell me that...
>> >
>> > ...you need to show us your code before we can have any chance of 
>> > helping.
>> >
>> > -Stut
>> >
>> > --
>> > http://stut.net/
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> -- 
> Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info 

--- End Message ---
--- Begin Message ---
On 6/24/07, Pieter du Toit <[EMAIL PROTECTED]> wrote:
But why is the php code showing just like my code at the top when i right
click the webpage and view source, i suspect this must be a php.ini setting
or sonmething

Yes, it might be.
That's why I asked you if you had short tags enabled or not, and that
you can better use <?php instead of <?.

Tijnema
"Tijnema" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 6/24/07, Pieter du Toit <[EMAIL PROTECTED]> wrote:
>> Nothing major here is the code:
>>
>> <?
>   ^^ Do you have short tags enabled?, try <?php
>
>> if ($_POST['name']) {
>
> Not the right way to check, you should use:
> if(isset($_POST['name']) {
>
>>
>> echo "name posted";
>>
>> }
>>
>> ?>
> <html code>
>
> If that still doesn't work, try a var_dump($_POST) at top of your
> script, and see if there's anything inside.
>
> Tijnema
>
>>
>> "Stut" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>> > Pieter du Toit wrote:
>> >> I installed PHP5 on iis and i can see "hello world" and phpinfo.
>> >>
>> >> When i right click the webpage and view source, i can see the php
>> >> code,
>> >> and the form does not want to post the form details.
>> >>
>> >> Will appreciate any help.
>> >
>> > My amazing psychic abilities tell me that...
>> >
>> > ...you need to show us your code before we can have any chance of
>> > helping.
>> >
>> > -Stut
>> >
>> > --
>> > http://stut.net/
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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




--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

--- End Message ---
--- Begin Message ---
On 6/24/07, Pieter du Toit <[EMAIL PROTECTED]> wrote:
In the php.ini?


Yes, short tags can be enabled in php.ini, and <?php is in your script ;)

Tijnema

ps. Please don't top-post

pps. When you reply to this list, add the PHP list in your Cc field.
Some mail clients have an  "Reply to all" button which does this
automatically:)

-----Original Message-----
From: Tijnema [mailto:[EMAIL PROTECTED]
Sent: Sunday, June 24, 2007 5:42 PM
To: Pieter du Toit
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] PHP not posting

On 6/24/07, Pieter du Toit <[EMAIL PROTECTED]> wrote:
> But why is the php code showing just like my code at the top when i right
> click the webpage and view source, i suspect this must be a php.ini
setting
> or sonmething

Yes, it might be.
That's why I asked you if you had short tags enabled or not, and that
you can better use <?php instead of <?.

Tijnema
> "Tijnema" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > On 6/24/07, Pieter du Toit <[EMAIL PROTECTED]> wrote:
> >> Nothing major here is the code:
> >>
> >> <?
> >   ^^ Do you have short tags enabled?, try <?php
> >
> >> if ($_POST['name']) {
> >
> > Not the right way to check, you should use:
> > if(isset($_POST['name']) {
> >
> >>
> >> echo "name posted";
> >>
> >> }
> >>
> >> ?>
> > <html code>
> >
> > If that still doesn't work, try a var_dump($_POST) at top of your
> > script, and see if there's anything inside.
> >
> > Tijnema
> >
> >>
> >> "Stut" <[EMAIL PROTECTED]> wrote in message
> >> news:[EMAIL PROTECTED]
> >> > Pieter du Toit wrote:
> >> >> I installed PHP5 on iis and i can see "hello world" and phpinfo.
> >> >>
> >> >> When i right click the webpage and view source, i can see the php
> >> >> code,
> >> >> and the form does not want to post the form details.
> >> >>
> >> >> Will appreciate any help.
> >> >
> >> > My amazing psychic abilities tell me that...
> >> >
> >> > ...you need to show us your code before we can have any chance of
> >> > helping.
> >> >
> >> > -Stut
> >> >
> >> > --
> >> > http://stut.net/
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> >
> > --
> > Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info





--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

--- End Message ---
--- Begin Message ---
Just a simple question (with a simple answer, hopefully): how can I access
character x of a utf-8 encoded string? i.e. how would I get this to work:

for($x=0; $x < strlen($utf8); $x++)
  echo "character {$x}:" . $utf8{$x};

Keep in mind that I have strlen overloaded by mbstring, and this is
necessary for my purposes because I need to do work on each character. Also,
by "character" I mean, for example: "我".

Thanks,
delsvr
-- 
View this message in context: 
http://www.nabble.com/PHP%2C-mbstring%2C-UTF-8-and-indexing-strings-tf3972397.html#a11275585
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message --- I'm really looking into using PHP as an all-round scripting language. I'm looking for a native looking UI toolkit, which takes PHP-GTK out the question.

I've seen wxWidgets but I can't find any bindings for PHP, unless anybody knows of any that I can't find?

Or, if anybody knows of any other native UI toolkits available for PHP? At least native linux and windows look.

Darren

--- End Message ---
--- Begin Message ---
ecc wrote:
> I really dont know, if this is the right board for this... but i think, i
> have to write it down.

if your looking to post a feature request then there is no list for that
- the bug database would be the place to do it ... but please don't bother the
devs with your feature request - it won't happen for reasons that are public 
record.

> 
> Please throw an error, if file_get_contents cant read a file because
> memory_limit overflow!

go read the archives of [EMAIL PROTECTED] for numerous reasons why that
it not going to happen.

> 
> I´ve programmed a tool parsing checksums from large files. Because i have to
> manage header-offsets, i have to read the files using file_get_contents.

given that your own comment in the example below states "while loop reading
the data! (This works!)" I can't see why you *have* to use file_get_contents()

have you tried filesize() and chcked the result is less than memory_limit?

> (This should be the fastest way for this task says the manual... right!)
> 
> The problem is, that if the memory_limit in the php.ini is set to 64MB, and
> the file read in by file_get_contents is bigger than 64MB, file_get_contents
> crashes without an EXCETPION. This crash cant be catched!

why do you think it should throw an exception? it won't, especially not a
particular class of exception that you made up o the spot.

php errors and exceptions are 2 different things, before going any
further you should read up on both so that you understand the difference.

> 
> I want handle this this way:
> 
> try{
>     $data = file_get_contents($file);
> }
> catch (MemoryLimitReachedException $e){
>     // try the same using a while loop reading the data! (This works!)
> }
> 
> Hope, there is a solution for this.
> 
> Thank you.
> Andreas
> http://www.php-gtk.eu/apps/emucontrolcenter
> 

--- End Message ---
--- Begin Message ---
hi all,
I have a news section on a website that im coding that isnt displaying properly. Every paragraph in each news post is being displayed as one big paragraph. how can i display my paragraphs in proper form? The field the news story is stored in is set as longtext.
here is a link to view.
http://area51.chalkthree.com/index.php?pg=3

the first update shows what im having an issue with. each item in the numbered list should be on a seperate line. there are some line breaks as well for new paragraphs that arent displaying properly.

here is the code i have:

                while($myrow = mysql_fetch_array($newsresults))
             {
             print "<br>";
                    print $myrow['news_topic'];
                    print "             ";
                    print $myrow['news_author'];
                    print "   ";
             print $myrow['topic_date'];
             print "<br>";
             print $myrow['news_message'];
                    print "<br>\n";
                                 }

_________________________________________________________________
Who's that on the Red Carpet? Play & win glamorous prizes. http://club.live.com/red_carpet_reveal.aspx?icid=REDCARPET_hotmailtextlink3
--- End Message ---

Reply via email to