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
Jewish Bear
Jul 28, 2007

Standish posted:

You also can't do
php:
<?
empty(someFunctionThatReturnsAString())?>
which bit me earlier today.

just do (functionthatreturns() == "")

see:
php:
<?php
function what($return)
{
    switch( $return )
    {
        case "boolean":
            return true;
            break;
            
        case "string":
            return "string";
            break;
            
        case "integer":
            return 1;
            break;
            
        case "array":
            return array("hello""goodbye");
            break;
            
        case "nothing":
            return;
            break;
    }
}
if( what("boolean") == "" )
{
    echo("what(bool) = nothing<br />");
}
if( what("string") == "" )
{
    echo("what(string) = nothing<br />");
}
if( what("integer") == "" )
{
    echo("what(int) = nothing<br />");
}
if( what("array") == "" )
{
    echo("what(array) = nothing");
}
if( what("nothing") == "" )
{
    echo("what(nothing) = nothing");
}
?>

returns:

what(nothing) = nothing

Adbot
ADBOT LOVES YOU

Jewish Bear
Jul 28, 2007

Mashi posted:

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 "".

Oh yeah I know I was just being lazy.

Jewish Bear
Jul 28, 2007

admiraldennis posted:

Don't you mean:

preg_match_all("#<br(?: /)?>#", $string, $m)

edit: can't quote your &lt;

correct :eng101:

Jewish Bear
Jul 28, 2007

Standish posted:

Use the cURL http library:
php:
<?php

$ch curl_init("http://myimageserver.com/image.jpg");

curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
$imagedata curl_exec($ch);
curl_close($ch);
?>

if cURL isn't enabled, use file_get_contents:
php:
<?php
$file file_get_contents'http://path/.jpg' );
header'Content-Type: image/jpeg' ); 
echo $file;
?>

Jewish Bear
Jul 28, 2007

opblaaskrokodil posted:

Edit: Why is that an error call within a header call anyway? I'm not familiar with VPet, but it seems like a weird thing to be doing

It probably returns a Location: header.

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