Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Mashi
Aug 15, 2005

Just wanted you to know your dinner's cold and the children all agree you're a shitheel!

LOL AND OATES posted:

yikes

Careful there. There is no such type in PHP as 'nothing', that use of return with no value actually returns NULL, and NULL, 0, and false are all equal to "".

Adbot
ADBOT LOVES YOU

Mashi
Aug 15, 2005

Just wanted you to know your dinner's cold and the children all agree you're a shitheel!

Zedlic posted:

The problem is that the table has 14 columns, and thousands of rows. The average query will return about 2.000 rows. So that's an array with around 30.000 strings, and quite possibly a lot more.

I'm not too experienced with PHP, is an array this big a silly thing to do? How big is too big?

It depends what problem you are trying to solve and what resources you have in greatest abundance. The situation that I've encountered large arrays in most is when creating reports from large amounts of data; in this case I would say yes, if it's going to save you a few massive queries or expensive joins, do it. But if this is something you want to do every time someone loads a page on your website then you might have a problem.

Try it out by running your script and printing out the value of get_peak_memory_usage() at the end, to see how much memory it used.

Mashi
Aug 15, 2005

Just wanted you to know your dinner's cold and the children all agree you're a shitheel!

Safety Shaun posted:

Without setting a cookie, session or global variable, I need to pass a variable from index.php to a PHP script included as an image.

I'm not quite sure but I think you are trying to prevent hotlinking:

Check the value of $_SERVER['HTTP_REFERER'] and deny access if:
a: There is a url, AND:
b: The address in that URL is not your website (I don't think you can safely rely on an accurate referrer always being present).

Mashi
Aug 15, 2005

Just wanted you to know your dinner's cold and the children all agree you're a shitheel!

awdio posted:

If header( 'Location: example.php' ); is placed at the top of a PHP script outside of a function, if statement or any other logic is the rest of the code guaranteed to run properly before it performs the header redirect?

I don't know about guarenteed to run properly (that would be nice wouldn't it?) but outputting a header will not disrupt the execution of your script at all.

Mashi
Aug 15, 2005

Just wanted you to know your dinner's cold and the children all agree you're a shitheel!
Well I suppose there is kind of a border case, where if you have already outputted something that isn't a header, then you'll get an error if you try to use the header() function (but I guess you knew that).

Adbot
ADBOT LOVES YOU

Mashi
Aug 15, 2005

Just wanted you to know your dinner's cold and the children all agree you're a shitheel!

Anveo posted:

Unless you're really disk bound, memcached is going to be about 5x slower than reading off local memory, and about 2x slower than reading off the disk.

The big benefit is that it is easily distributed, not that it is faster.

Eh? How is it going to be slower than reading from the disk? Memcached stores information in memory.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply