php-general Digest 12 Jun 2005 14:27:41 -0000 Issue 3508

Topics (messages 216854 through 216863):

Re: Is there a big speed difference...
        216854 by: Richard Lynch
        216863 by: Brian Dunning

Re: http to https session problem
        216855 by: Richard Lynch
        216856 by: Joe Harman

Re: The "goto" discussion on the Internals List
        216857 by: Richard Lynch

Re: Compilation trouble on OS X
        216858 by: Richard Lynch

Re: weird thing; downloading from a php script stops at exactly 2.000.000 bytes
        216859 by: Richard Lynch

Re: output buffering / output compression
        216860 by: Richard Lynch

Re: Converting a query for use in a form
        216861 by: Richard Lynch

Documenting Code Question
        216862 by: Chris Drozdowski

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 Thu, June 9, 2005 10:06 am, Brian Dunning said:
>
> On Jun 9, 2005, at 9:48 AM, bruce wrote:
>
>> bian...
>>
>> giave a psuedocode example of what you're trying to compare.. i
>> think i know
>> what you're asking, but i want to be sure..
>
> OK, this is *pseudocode* remember...  :)
>
> Is either of these SIGNIFICANTLY slower:
>
> === Example 1 ===
>
> while(loops 5000 times)
> {
>      include(myfunction.php);

Assuming there is not function in myfunction.php, and it's just raw
PHP/HTML code...

This is slower, UNLESS you have something like Zend Cache (or whatever
it's called now) *AND* that is configured to not check filemtime on every
hit...

At that point, this could probably be faster.

> }
>
> ...where myfunction.php contains some code.
>
> === Example 2 ===
>
> include_once(myfunction.php);
> while(loops 5000 times)
> {
>      myfunction(xxx);
> }
>
> ...where myfunction.php defines the function myfunction().

The overhead for a function is not zero, but it also depends a little bit
on what arguments you are passing to the function.

Have you actually tried it yet, either way?

Cuz I suspect you are worrying over a lot of nothing...

Try it the cleanest most maintainable way.

Worry about performance after it fails.

"Look before you leap" is good advice, but not when don't have enough data
to "look" -- Find out if it's "too slow" then make an informed decision.

Especially for 6 lines of code.

5,000 iterations isn't gonna kill you, I'll bet.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Jun 11, 2005, at 6:24 PM, Richard Lynch wrote:

Have you actually tried it yet, either way?
Cuz I suspect you are worrying over a lot of nothing...

I did post the results a couple of days ago. Switching to a function made an enormous difference. It went from an average of 45 seconds to an average of 2 seconds.
--- End Message ---
--- Begin Message ---
On Thu, June 9, 2005 7:43 am, Joe Harman said:
> I am having a little problem with users keeping the same session id
> when they go from http to https... is there a work around for this...
> I don't appear to have this problem when using openSSL just when the
> site has it's own certificate.
>
> should I store the session id in a cookie??? or is there another way or
> setting

A Cookie would be a fine way to pass it, or in the URL.

You probably have a very clear user-interaction-path into and out of SSL
anyway, so you'd only be changing a couple lines of code, in a
well-designed application.

Essentially, it's probably best to think of your HTTP and HTTPS as two
totally different servers, with nothing in common, even when, in fact,
they are the same server with the same files in the same exact hard drive
and all that.

Some hosts split HTTPS off on another box ; Some don't.

If you're ready for the split, you're more mobile.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On 6/11/05, Joe Harman <[EMAIL PROTECTED]> wrote:
> On 6/11/05, Richard Lynch <[EMAIL PROTECTED]> wrote:
> > On Thu, June 9, 2005 7:43 am, Joe Harman said:
> > > I am having a little problem with users keeping the same session id
> > > when they go from http to https... is there a work around for this...
> > > I don't appear to have this problem when using openSSL just when the
> > > site has it's own certificate.
> > >
> > > should I store the session id in a cookie??? or is there another way or
> > > setting
> >
> > A Cookie would be a fine way to pass it, or in the URL.
> >
> > You probably have a very clear user-interaction-path into and out of SSL
> > anyway, so you'd only be changing a couple lines of code, in a
> > well-designed application.
> >
> > Essentially, it's probably best to think of your HTTP and HTTPS as two
> > totally different servers, with nothing in common, even when, in fact,
> > they are the same server with the same files in the same exact hard drive
> > and all that.
> >
> > Some hosts split HTTPS off on another box ; Some don't.
> >
> > If you're ready for the split, you're more mobile.
> >
> > --
> > Like Music?
> > http://l-i-e.com/artists.htm
> >
> >
> 
> Yep... i am going to have to keep something in a cookie to identify
> the user if they come back to the site... I was trying to avoid the
> whole P3P things with cookies... not that it's hard... it's jsut a
> pain in the butt :o)
> 
> Thanks! Cheers!
> 

Yep... i am going to have to keep something in a cookie to identify
the user if they come back to the site... I was trying to avoid the
whole P3P things with cookies... not that it's hard... it's jsut a
pain in the butt :o)

Thanks! Cheers!
-- 
Joe Harman
---------
Do not go where the path may lead, go instead where there is no path
and leave a trail. - Ralph Waldo Emerson

--- End Message ---
--- Begin Message ---
On Thu, June 9, 2005 6:49 am, Jochem Maas said:
> Richard Lynch wrote:
>> And, for the record, *I* sure as hell don't want to see a GoTo in PHP.
>
> whats your take on ifsetor()?, personally I would like to see it. I think
> its a great way to teach newbies about checking vars before use (if
> nothing
> else)

This probably doesn't belong on this list, but I was asked here, so I'll
answer here. [Plus I'm not on the internals list.]  Re-direct followups
off-list or back to -internals or ...

I don't think ifsetor is going to encourage newbies to check variables
before use.

In fact, I think it's just going to confuse newbies with one more extra
way to do the same thing.

Only turning E_ALL on by default (which I asked for in PHP 4.0 and PHP 5.0
and will ask again for PHP 6.0 and 7.0 and 8.0 ...) will actually educate
newbies that they are doing something fundamentaly "wrong" in their
Programming to use variables they haven't initialized.
Spare the rod, spoil the child.
Spare the E_NOTICE, spoil the newbie.

There's currently NOTHING other than 10,000 pages of docs to tell a newbie
they NEED to check vars.

The quickie examples everybody rattles off don't check vars.

The MANUAL doesn't even consistently use good programming practices in its
examples -- though it gets better over time, mostly.

Then people want to "simplify" the examples down to just the
function/feature in question, and we go back to Bad Code.

ifsetor doesn't really seem to add much value to me.

$foo $: $default;
$foo = ifsetor($default);
$foo = isset($foo) ? $foo : $default;

What?  15 to 20 characters, depending on the ifsetor syntax?

I'll pass.

I don't think ifsetor adds enough value to the language to be worth the
confusion of having a second way to do the same thing in ~20 more
characters, personally.

[shrug]

If it gets added, I'll probably never even bother to use it.  I've been
typing the isset() ? : construct for so many years, that I'm not gonna
switch for the sake of a few less keystrokes.  Sorry.

I certainly don't want to be the one answering the 10,000 emails to this
list:

Which is better? isset() ? : or ifsetor?

Which one is faster?

Why are there two ways to do this?

What's this ifsetor thing? / What's this isset() ? : thing?

And then the arguments between the experts (self included) over which one
is "better" and why.

Cuz I'll tell you right here, right now, that's one consequence of this
proposed change.  10,000 more emails to php-general in the next year or
two, just about 'ifsetor'.

My vote, if anybody cares to count it:

-1

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Thu, June 9, 2005 5:32 am, Marcus Bointon said:
> I've been beating my head against this  - I've done this so many
> times on BSD and Linux but I just can't get PHP 5.0.4 to compile on
> OS X. Even the simplest case:
>
> ./configure
> make
>
> fails with:
>
> /usr/bin/ld: Undefined symbols:
> _mbstring_globals
> _php_mb_encoding_translation

I vaguely recall an issue with mb_* where people saw this nifty new
feature and turned it on having no idea what it was, and, well, they
didn't really want that feature turned on at all...

This could be the same thing.

Or not.

Try ./configure --without-mbstring

Only you'll have to check ./configure --help | grep mb

and see how to actually turn it off.

-- 
Like Music?
http://l-i-e.com/artists.htm

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

I just noticed the eaccelerator bit in this thread.

Just disabling eaccelerator isn't the same as not compiling it in in the
first place...

Try that before reporting a bug to http://bugs.php.net

On Thu, June 9, 2005 1:59 am, Catalin Trifu said:
>       Hi,
>
>    I installed php5 using the configue below. I tried with apache2 as well
> and same things.
>
> './configure' '--prefix=/usr/local/php5'
> '--with-apxs=/usr/local/apache/bin/apxs' '--disable-cgi'
> '--with-config-file-path=/etc/php5' '--with-dom' '--with-gd'
> '--enable-sockets' '--enable-exif'
> '--with-freetype2' '--with-freetype-dir=/usr/include/freetype2'
> '--enable-gd-native-ttf'
> '--with-zlib-dir=/usr' '--with-curl' '--with-curlwrappers' '--enable-ftp'
> '--with-mysql=/usr'
> '--with-xsl' '--with-libxml-dir=/usr'
>
>    I have a script which generates a temporary catalog file, which is
> generated correctly having
> 4.7MB on disk.
>    Then I push up the wire with readfile($filname):
>
>    header("Content-Type: text/csv");
>    header("Content-Disposition: attachment; filename=somfilename.csv");
>    header("Content-Length: ". filesize($file));
>
>    readfile($file);
>
>
>    As expected the browser starts the download and reports it is expecting
> a file of 4.7MB.
>    However, the download stops at 2.000.000 bytes no matter what browser I
> use (normally i use
> Firefox on Linux), no matter if php runs on apache2 or apache1.3
>
>    Is there some php config option I missed ?
>    Where could this come from ?
>
>
> Thanks,
> Catalin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Thu, June 9, 2005 12:22 am, Paul Birnstihl said:
> I have recently set up a machine with PHP with both buffering and
> compression turned on. Some of the pages being served include up to 3MB
> of HTML.
>
> Can someone explain the benefit(s) of setting these ini directives to
> values (ie. larger than 4kb) rather than "On" ?
>
> I've played around with it as I thought it might speed things up by
> using a bigger buffer etc. but the only difference I noticed is a big
> jump in memory usage.

If you somehow manage to spew out more than 3MB before you try to call
header() or session_start() or whatever, then the buffer got dumped, and
it's too late.

At least, that's how I think it would work...

But I never turn buffering on anyway, so what do I know?

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Wed, June 8, 2005 9:59 pm, [EMAIL PROTECTED] said:
> I hope you can all help me. I want to take the information I get from a
> query and use it is a form as a dropdown select box. For example I want to
> pull the colors from a table and list them in a drop down box and then
> when
> a user selects a color it will pass the colorID for use in writing to
> another table. I hope that comes across the way I mean. :-( Anyway, I
> think
> I used to use something called wddx with java to do this when I was coding
> in ColdFusion.

<?php
  $color = isset($_REQUEST['color']) ? $color : 'white';
  $query = "select color from soaps";
  $colors = mysql_query($query, $connection) or
error_log(mysql_error($connection) . " $query");
  $kosher = false;
  echo "<select name=\"color\">\n";
  while (list($c) = mysql_fetch_row($colors)){
    //Cheap and easy data scrubbing:
    if ($c == $color) $kosher = true;
    $selected = $c == $color ? 'SELECTED' : '';
    echo "<option $selected>$c</option>\n";
  }
  echo "</select>\n";
  //If they didn't pick a valid color, make it white
  if (!$kosher) $color = 'white';
  //Or log their IP
  //Or raise a Red Alert.
  //Or Whatever.
?>

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message --- I need some help regarding documenting code. Say you have a function/method that takes an object as a parameter and/or returns an object.

When documenting, do you specify the specific class of the object when listing the datatype in the docblock @param and @return specs or do you simply specify "object"?


Thanks,

Chris Drozdowski
[EMAIL PROTECTED]

--- End Message ---

Reply via email to