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

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


On Sat, May 9, 2009 at 10:16 PM, Robert Cummings wrote:

> 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:
> >
> >
> >  >
> >  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


[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] 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"  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



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] 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  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] intval

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

and.


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] 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:
> 
> 
>  
>  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 Robert Cummings
On Sat, 2009-05-09 at 21:23 +0530, kranthi wrote:
> k i ended up with this code
> 
>  
> $_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



[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:





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 kranthi
k i ended up with this code



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



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:



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
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] 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 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)



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



[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] 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