php-general Digest 9 May 2009 12:42:16 -0000 Issue 6112

2009-05-09 Thread php-general-digest-help

php-general Digest 9 May 2009 12:42:16 - Issue 6112

Topics (messages 292412 through 292415):

Re: CURL error help
292412 by: Jônatas Zechim

Re: how to enable ttf support in php 5.2.9
292413 by: Ross McKay

Re: Problems with HTTPS and maybe an .htaccess???
292414 by: Ross McKay

Re: php-gene...@lists.php.net, Tim-Hinnerk Heuer has invited you to open a 
Google mail account
292415 by: Nathan Rixham

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---
U r correct! It's ok know.


-Mensagem original-
De: Shawn McKenzie [mailto:nos...@mckenzies.net] 
Enviada em: sexta-feira, 8 de maio de 2009 13:34
Para: Miller, Terion
Cc: Jônatas Zechim; PHP-General List
Assunto: Re: RES: RES: RES: [PHP] CURL error help

Miller, Terion wrote:
 
 
 On 5/8/09 10:55 AM, Jônatas Zechim zechim@gmail.com wrote:
 
 Ok, but u need to confirm  the $args vars are being passed to that
funtion,
 because I thing they're blanks.
 
 Zechim
 zechim.com
 São Paulo/Brazil
 
 here is the code from the dom.php file, as it stands currently my error
reads:
 
 
 Warning: file_get_contents($target_url) [function.file-get-contents]:
failed to open stream: No such file or directory in
/var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/inc/dom.php
on line 39
 
 Here is the code from dom.php:
 
 
 define('HDOM_TYPE_ELEMENT', 1);
 define('HDOM_TYPE_COMMENT', 2);
 define('HDOM_TYPE_TEXT',3);
 define('HDOM_TYPE_ENDTAG',  4);
 define('HDOM_TYPE_ROOT',5);
 define('HDOM_TYPE_UNKNOWN', 6);
 define('HDOM_QUOTE_DOUBLE', 0);
 define('HDOM_QUOTE_SINGLE', 1);
 define('HDOM_QUOTE_NO', 3);
 define('HDOM_INFO_BEGIN',   0);
 define('HDOM_INFO_END', 1);
 define('HDOM_INFO_QUOTE',   2);
 define('HDOM_INFO_SPACE',   3);
 define('HDOM_INFO_TEXT',4);
 define('HDOM_INFO_INNER',   5);
 define('HDOM_INFO_OUTER',   6);
 define('HDOM_INFO_ENDSPACE',7);
 
 // helper functions
 //

-
 // get html dom from file
 function file_get_html() {
$dom = new simple_html_dom;
$args = func_get_args();
$dom-load(call_user_func_array('file_get_contents', $args), true);
return $dom;
 
 }
 
 // get html dom from string
 function str_get_html($str, $lowercase=true) {
$dom = new simple_html_dom;
$dom-load($str, $lowercase);
return $dom;
 }
 
 // dump html dom tree
 function dump_html_tree($node, $show_attr=true, $deep=0) {
$lead = str_repeat('', $deep);
echo $lead.$node-tag;
if ($show_attr  count($node-attr)0) {
echo '(';
foreach($node-attr as $k=$v)
echo [$k]=\.$node-$k.', ';
echo ')';
}
echo \n;
 
foreach($node-nodes as $c)
dump_html_tree($c, $show_attr, $deep+1);
 }
 
 // get dom form file (deprecated)
 function file_get_dom() {
$dom = new simple_html_dom;
$args = func_get_args();
$dom-load(call_user_func_array('file_get_contents', $args), true);
return $dom;
 }
 
 // get dom form string (deprecated)
 function str_get_dom($str, $lowercase=true) {
$dom = new simple_html_dom;
$dom-load($str, $lowercase);
return $dom;
 }
 
 

I've answered your question.  It's not in that file it's in your
function call to file_get_html().  You've got your parameter variable in
single frigging quotes!

-- 
Thanks!
-Shawn
http://www.spidean.com

---End Message---
---BeginMessage---
On Tue, 5 May 2009 17:27:57 -0400, tedd.sperling wrote:

I have one client who no matter how many times I talk to him about 
gremlins and how he should make sure his entries are plain text, he 
still cuts and paste things directly from M$ Word and then wonders 
Where did those come from? They weren't there when I added that 
text. What did you do?

If that's using TinyMCE, enable the Paste From Word button (or the Paste
as Plain Text button) and disable the regular Paste button :)
-- 
Ross McKay, Toronto, NSW Australia
Pay no attention to that man behind the curtain - Wizard of Oz
---End Message---
---BeginMessage---
On Tue, 05 May 2009 13:20:56 -0500, Skip Evans wrote:

[...]
But now I have a problem implementing this on their 
development site, which is just a duplicate code base inside a 
directory public_html/_dev and a domain name dev.sitename.com, 
instead of sitename.com.

The problem is, and I believe it may be the .htaccess file, 
redirecting the https pages to the live [...]

You should be telling the browser to redirect to the new page, rather
than just pulling up a page to offer back instead of the requested URL.
You want the browser to request a new page, using HTTPS (i.e. SSL or
TLS). See here, which forces a redirect to HTTPS for any pages in the

php-general Digest 10 May 2009 04:43:00 -0000 Issue 6113

2009-05-09 Thread php-general-digest-help

php-general Digest 10 May 2009 04:43:00 - Issue 6113

Topics (messages 292416 through 292430):

intval
292416 by: kranthi
292417 by: Robert Cummings
292419 by: kranthi
292420 by: Robert Cummings
292421 by: kranthi
292423 by: Robert Cummings
292425 by: kranthi

Re: php-gene...@lists.php.net, Tim-Hinnerk Heuer has invited you to open a 
Google mail account
292418 by: Lenin
292426 by: דניאל דנון
292427 by: Lenin

Something I don't understand about PHP classes
292422 by: Cesco
292424 by: Robert Cummings
292430 by: chetan rane

Re: Session data files
292428 by: phphelp -- kbk

Trying to create a colortable - what am I missing here?
292429 by: דניאל דנון

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---
Hi,

var_dump($_POST['month'], intval($_POST['month']), $_POST['month'] ==
((int)($_POST['month']));
var_dump($_POST['month'], intval($_POST['month']), $_POST['month'] ==
(intval($_POST['month'])));

is giving me
string(3) Jan int(0) bool(true)
but i m expecting
string(3) Jan int(0) bool(false)

ny ideas y this is happening??

Kranthi.
---End Message---
---BeginMessage---
On Sat, 2009-05-09 at 18:22 +0530, kranthi wrote:
 var_dump($_POST['month'], intval($_POST['month']), $_POST['month'] ==
 ((int)($_POST['month']));
 var_dump($_POST['month'], intval($_POST['month']), $_POST['month'] ==
 (intval($_POST['month'])));

After I fixed your syntax error this worked fine for me in PHP 5.2.9:

string(3) Jan
int(0)
bool(true)
string(3) Jan
int(0)
bool(true)

?php

$_POST['month'] = 'Jan';

var_dump( $_POST['month'], intval( $_POST['month'] ), $_POST['month'] ==
(int)$_POST['month'] );
var_dump( $_POST['month'], intval( $_POST['month'] ), $_POST['month'] ==
intval( $_POST['month'] ) );

?

Your use of parenthesis shows you lack understanding of operator and
function use. All those parenthesis generally make things less readable
despite your best intentions to clarify the process.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP

---End Message---
---BeginMessage---
thanks for the reply... just happened to see http://php.net/ternary
which explains the above result

i want to explicitly type cast all the numbers passed via post (by
default they are strings)
is_numeric() is a option, but it will not be possible to differentiate
between int and float.

$_POST['month'] !== (string)(int)$_POST['month']
this is exactly what i want... but wont this take up memory when used
with array_walk_recursive() ?
---End Message---
---BeginMessage---
On Sat, 2009-05-09 at 20:02 +0530, kranthi wrote:
 thanks for the reply... just happened to see http://php.net/ternary
 which explains the above result
 
 i want to explicitly type cast all the numbers passed via post (by
 default they are strings)
 is_numeric() is a option, but it will not be possible to differentiate
 between int and float.
 
 $_POST['month'] !== (string)(int)$_POST['month']
 this is exactly what i want... but wont this take up memory when used
 with array_walk_recursive() ?

Just add the value to 0 and PHP will do the juggling for you:

?php

$_POST = array( '1', '100', '100.1', '100.123' );

foreach( $_POST as $value )
{
$value = 0 + $value;

echo 'Value: ';
var_dump( $value );
}

?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP

---End Message---
---BeginMessage---
k i ended up with this code

?php

$_POST = array( '1', '100', '100.1', '100.123', 'a');

foreach( $_POST as $value )
{
if(is_numeric($value)) {
$value = $value + 0;
}
}
var_dump($_POST);

?

its giving me
array(5) { [0]=  int(1) [1]=  int(100) [2]=  float(100.1) [3]=
float(100.123) [4]=  string(1) a }
what does string mean ??
---End Message---
---BeginMessage---
On Sat, 2009-05-09 at 21:23 +0530, kranthi wrote:
 k i ended up with this code
 
 ?php
 
 $_POST = array( '1', '100', '100.1', '100.123', 'a');
 
 foreach( $_POST as $value )
 {
   if(is_numeric($value)) {
   $value = $value + 0;
   }
 }
 var_dump($_POST);
 
 ?
 
 its giving me
 array(5) { [0]=  int(1) [1]=  int(100) [2]=  float(100.1) [3]=
 float(100.123) [4]=  string(1) a }
 what does string mean ??

Maybe because you assigned values from $_POST to $value with the reference 
operator?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP

---End Message---
---BeginMessage---
if that is the case  should appear before all the other variables as well

and.
?php
function foo($val, $key) {
 if(is_numeric($value)) {
  

Re: [PHP] php-general@lists.php.net, Tim-Hinnerk Heuer has invited you to open a Google mail account

2009-05-09 Thread Nathan Rixham

Lenin wrote:

Yeah gmail is a nice thing :)

The best ever mailing system world has ever seen until now.



Because now you can get new LeninMail from phpXperts - it works offline, 
it works in your fridge, you car, your bath, everywhere conventional 
mail doesn't work.


LeninMail combines all the power of E with all the functionality of G to 
give you a new experience unparalleled by any other technology.


Sheena from Cambridge:
LeninMail is sooo good, all I need is one spoonful in my bath and 
I'm ready to communicate, stubborn limescale used to be a real headache, 
but now I just LeninMail it away.


James Smith JNR from Ghana
LeninMail is amazing - its handy SendAnythingAnywhere feature has 
allowed me to be lmailing my grade A spam from everywhere I go - and 
with LeninMails ForceItThrough technology I know my spam will be 
penetrating millions of peoples brains in seconds. LMail has made me 
rich and now I have 60 million that I need to transfer to you, all you 
need to do is send me a 1% security fee to..


L is over FIVE letters after G and even more than E - so much power - 
such bigger numbers.


BANG and the mail is gone.

Get LeninMail from all good phpXperts stockists NOW!

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



[PHP] intval

2009-05-09 Thread kranthi
Hi,

var_dump($_POST['month'], intval($_POST['month']), $_POST['month'] ==
((int)($_POST['month']));
var_dump($_POST['month'], intval($_POST['month']), $_POST['month'] ==
(intval($_POST['month'])));

is giving me
string(3) Jan int(0) bool(true)
but i m expecting
string(3) Jan int(0) bool(false)

ny ideas y this is happening??

Kranthi.

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



Re: [PHP] intval

2009-05-09 Thread Robert Cummings
On Sat, 2009-05-09 at 18:22 +0530, kranthi wrote:
 var_dump($_POST['month'], intval($_POST['month']), $_POST['month'] ==
 ((int)($_POST['month']));
 var_dump($_POST['month'], intval($_POST['month']), $_POST['month'] ==
 (intval($_POST['month'])));

After I fixed your syntax error this worked fine for me in PHP 5.2.9:

string(3) Jan
int(0)
bool(true)
string(3) Jan
int(0)
bool(true)

?php

$_POST['month'] = 'Jan';

var_dump( $_POST['month'], intval( $_POST['month'] ), $_POST['month'] ==
(int)$_POST['month'] );
var_dump( $_POST['month'], intval( $_POST['month'] ), $_POST['month'] ==
intval( $_POST['month'] ) );

?

Your use of parenthesis shows you lack understanding of operator and
function use. All those parenthesis generally make things less readable
despite your best intentions to clarify the process.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] php-general@lists.php.net, Tim-Hinnerk Heuer has invited you to open a Google mail account

2009-05-09 Thread Lenin
Hahaha quite Hilarious.

le...@phpxperts.net is also hosted by Google Apps :P

Its the Largest active PHP group in South Asia (originated from Bangladesh).
Participated by thousands from many other countries.

Keep the humor on! :D


Re: [PHP] intval

2009-05-09 Thread kranthi
thanks for the reply... just happened to see http://php.net/ternary
which explains the above result

i want to explicitly type cast all the numbers passed via post (by
default they are strings)
is_numeric() is a option, but it will not be possible to differentiate
between int and float.

$_POST['month'] !== (string)(int)$_POST['month']
this is exactly what i want... but wont this take up memory when used
with array_walk_recursive() ?

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



Re: [PHP] intval

2009-05-09 Thread Robert Cummings
On Sat, 2009-05-09 at 20:02 +0530, kranthi wrote:
 thanks for the reply... just happened to see http://php.net/ternary
 which explains the above result
 
 i want to explicitly type cast all the numbers passed via post (by
 default they are strings)
 is_numeric() is a option, but it will not be possible to differentiate
 between int and float.
 
 $_POST['month'] !== (string)(int)$_POST['month']
 this is exactly what i want... but wont this take up memory when used
 with array_walk_recursive() ?

Just add the value to 0 and PHP will do the juggling for you:

?php

$_POST = array( '1', '100', '100.1', '100.123' );

foreach( $_POST as $value )
{
$value = 0 + $value;

echo 'Value: ';
var_dump( $value );
}

?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] intval

2009-05-09 Thread kranthi
k i ended up with this code

?php

$_POST = array( '1', '100', '100.1', '100.123', 'a');

foreach( $_POST as $value )
{
if(is_numeric($value)) {
$value = $value + 0;
}
}
var_dump($_POST);

?

its giving me
array(5) { [0]=  int(1) [1]=  int(100) [2]=  float(100.1) [3]=
float(100.123) [4]=  string(1) a }
what does string mean ??

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



[PHP] Something I don't understand about PHP classes

2009-05-09 Thread Cesco
Ok, I suppose that this should be a very simple problem and probably  
the answer is obvious, but I really can't understand how the classes  
and the rest of the stuff works in PHP...


Let's suppose that we have this piece of code:


?php

class Duck {

function __construct() {

while(1==1) {
// This is an infinite loop
}

}   
}

echo Hello world...;
$DonaldDuck = new Duck();

?


I have put an infinite loop in the class constructor just to introduce  
a problem that will halt the execution of the PHP code.


Now, If I run this code I would expect that the PHP interpreter would  
print the Hello world... string, and then it should call the class  
constructor with the infinite loop inside of it.


But that doesn't happen.

Instead, the PHP interpreter enters IMMEDIATELY into an infinite loop,  
as if the variables were declared immediately and then the rest of the  
code is executed.


Is it right? Because I'm having really hard times in debugging a PHP  
class


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



Re: [PHP] intval

2009-05-09 Thread Robert Cummings
On Sat, 2009-05-09 at 21:23 +0530, kranthi wrote:
 k i ended up with this code
 
 ?php
 
 $_POST = array( '1', '100', '100.1', '100.123', 'a');
 
 foreach( $_POST as $value )
 {
   if(is_numeric($value)) {
   $value = $value + 0;
   }
 }
 var_dump($_POST);
 
 ?
 
 its giving me
 array(5) { [0]=  int(1) [1]=  int(100) [2]=  float(100.1) [3]=
 float(100.123) [4]=  string(1) a }
 what does string mean ??

Maybe because you assigned values from $_POST to $value with the reference 
operator?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Something I don't understand about PHP classes

2009-05-09 Thread Robert Cummings
On Sat, 2009-05-09 at 18:35 +0200, Cesco wrote:
 Ok, I suppose that this should be a very simple problem and probably  
 the answer is obvious, but I really can't understand how the classes  
 and the rest of the stuff works in PHP...
 
 Let's suppose that we have this piece of code:
 
 
 ?php
 
  class Duck {
   
   function __construct() {
   
   while(1==1) {
   // This is an infinite loop
   }
   
   }   
  }
   
   echo Hello world...;
   $DonaldDuck = new Duck();
   
 ?
 
 
 I have put an infinite loop in the class constructor just to introduce  
 a problem that will halt the execution of the PHP code.
 
 Now, If I run this code I would expect that the PHP interpreter would  
 print the Hello world... string, and then it should call the class  
 constructor with the infinite loop inside of it.
 
 But that doesn't happen.
 
 Instead, the PHP interpreter enters IMMEDIATELY into an infinite loop,  
 as if the variables were declared immediately and then the rest of the  
 code is executed.
 
 Is it right? Because I'm having really hard times in debugging a PHP  
 class

Presumably you're doing this on the shell (versus in a web page). You
need to send the newline (\n) character since most terminals buffer
the output until a newline character is encountered. If htis is a
webpage you are in for even more trouble since browser often won't
output anything until they receive at least X bytes (where X depends on
the browser).

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] intval

2009-05-09 Thread kranthi
if that is the case  should appear before all the other variables as well

and.
?php
function foo($val, $key) {
 if(is_numeric($value)) {
   $value = $value + 0;
  }
}
$_POST = array( '1', '100', '100.1', '100.123', 'a');
array_walk_recursive($_POST, 'foo');
var_dump($_POST);
?

is giving me
array(5) { [0]=  int(1) [1]=  int(100) [2]=  float(100.1) [3]=
float(100.123) [4]= string(1) a }
ny idea y this difference arises?

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



Re: [PHP] php-general@lists.php.net, Tim-Hinnerk Heuer has invited you to open a Google mail account

2009-05-09 Thread דניאל דנון
That's how you help information-monster-privacy-killing-companies to gain
more control...

You use GMail? ever visited blogspot? search on Google? Visit half of the
leading sites of the world (since they have Google Analytics) or visit the
other half that have Google Adsense or both of them?
Maybe you use Google Chrome? Google Earth? Google Desktop? Android? Google
_?

You think that it? now it aims for you, the programmers. Use the nice
Google AJAX API? so comfortable, lightweight
Yes, now Google can collect MORE information.

Yes? thank you by helping Google. if you use Google softwares, please click
CTRL+ALT+DELETE, go to proccess, look for GoogleUpdate.exe and wonder why is
it there? oh, now you remember? use Google Earth/Desktop/ ?

Thank you for helping Google in another step for becoming an
information-monster.

If anyone wants - I made a presentation about Privacy and how Google
infiltrates your privacy.

(I know someone will smile and say but hey - you use Gmail. I'll just
smile back and say that using gmail isn't bad - but using Google all the
time IS bad).

Watch how many large organizations have protested about Google way (of
tracking you, as individiual, for over 18 months).

Now someone again will point that What do I mind if they are following
me? I am not doing anything illegal.
No, I am not saying the government will use this information - The FBI
have asked all search engines to give him data about searches that might
relate to criminal activities. they all gave. Except Google.

What do they do with this information? Google Adsense, Analytics, News,
Search, Images, API, Code.
Blogspot, Adwords, should I continue this list of Google products that I am
sure that each one of you was exposed to?


On Sat, May 9, 2009 at 12:27 AM, Lenin le...@phpxperts.net wrote:

 Yeah gmail is a nice thing :)

 The best ever mailing system world has ever seen until now.




-- 
Use ROT26 for best security


Re: [PHP] php-general@lists.php.net, Tim-Hinnerk Heuer has invited you to open a Google mail account

2009-05-09 Thread Lenin
LOL good points indeed!

But I dont use other Google products that much. But yes I'm helping google
in some way.

One great satisfaction I have is I use Ubuntu with FireFox. :)


Re: [PHP] Session data files

2009-05-09 Thread phphelp -- kbk

Thanks, Tom - -


On May 8, 2009, at 12:37 PM, Tom Worster wrote:


On 5/8/09 11:09 AM, phphelp -- kbk phph...@comcast.net wrote:


Just something I'm curious about: When I run PHP on my development
box (W2K), I just get one session file per connection which gets
deleted (usually) after the session expires.

When I look at the session files on the client server (linux/apache),
there seems to be one session file per page click. I needed to clear
them a few minutes ago, and there are already 80+ files, and this is
just from one user (a tester -- this is in late-late-late beta).

Now, there is nothing wrong -- everything is working fine -- I am
just curious if Apache does this differently, or if there is a
configuration setting that governs this (I haven't found -- but only
did a cursory look).

Anybody willing to take the time to enlighten me?


have you satisfied yourself that what you're seeing is not just an  
artifact

of how the session garbage collector works?

http://us.php.net/manual/en/session.configuration.php

maybe compare the gc parameters on the two different machines?  
phpinfo()

displays the values.





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



[PHP] Trying to create a colortable - what am I missing here?

2009-05-09 Thread דניאל דנון
I've tried to make a color table, but I am missing something. not in the
color-table-code itself, but in somewhere else... I just can't find...

error_reporting is E_ALL, running it on my local server, the script has
512MB to spend, no errors occurs - just something, is wrong.

(4072 * 4072 ~= 255*255*255)

The problem is that the result image only contains all the blue(0,0,0 |
0,0,1 | 0,0,2 . 0,0,255) and the rest is black.

I've tried anything, did echo X{$i % 4072}Y{LONG_Y_CODE}:{$r}-{$g}-{$b}\n;
All seems to be correct, what am I missing here? PHP 5.2.8

$im = imagecreate(4072, 4073);
$white = imagecolorallocate($im, 0, 0, 0);
$r = $g = $b = $i =  0;
$max = 255;
while ($r = $max) {
while ($g = $max) {

while ($b = $max) {

$n = imagecolorallocate($im, $r, $g, $b);
imagesetpixel($im, ($i % 4072), (($i - ($i % 4072)) / 4072),
$n);


$i++;
$b++;
}
$b = 0;
$g++;
}
$g = 0;
$r++;
}
header(Content-Type: image/png);
imagepng($im);
imagedestroy($im);

-- 
Use ROT26 for best security


Re: [PHP] Something I don't understand about PHP classes

2009-05-09 Thread chetan rane
Hi
you can use the following code
?php

  class Duck {

   function __construct() {

   while(1==1) {
   // This is an infinite loop
   }

   }
  }

   echo Hello world...;
   flush();
   $DonaldDuck = new Duck();

  ?

On Sat, May 9, 2009 at 10:16 PM, Robert Cummings rob...@interjinn.comwrote:

 On Sat, 2009-05-09 at 18:35 +0200, Cesco wrote:
  Ok, I suppose that this should be a very simple problem and probably
  the answer is obvious, but I really can't understand how the classes
  and the rest of the stuff works in PHP...
 
  Let's suppose that we have this piece of code:
 
 
  ?php
 
   class Duck {
 
function __construct() {
 
while(1==1) {
// This is an infinite loop
}
 
}
   }
 
echo Hello world...;
$DonaldDuck = new Duck();
 
  ?
 
 
  I have put an infinite loop in the class constructor just to introduce
  a problem that will halt the execution of the PHP code.
 
  Now, If I run this code I would expect that the PHP interpreter would
  print the Hello world... string, and then it should call the class
  constructor with the infinite loop inside of it.
 
  But that doesn't happen.
 
  Instead, the PHP interpreter enters IMMEDIATELY into an infinite loop,
  as if the variables were declared immediately and then the rest of the
  code is executed.
 
  Is it right? Because I'm having really hard times in debugging a PHP
  class

 Presumably you're doing this on the shell (versus in a web page). You
 need to send the newline (\n) character since most terminals buffer
 the output until a newline character is encountered. If htis is a
 webpage you are in for even more trouble since browser often won't
 output anything until they receive at least X bytes (where X depends on
 the browser).

 Cheers,
 Rob.
 --
 http://www.interjinn.com
 Application and Templating Framework for PHP


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




-- 
Have A pleasant Day
Chetan. D. Rane
Location: India
Contact: +91-9986057255
other ID: chetsc...@yahoo.com
chetr...@rediffmail.com