Home > Archive > PHP Language > August 2005 > Total nOOb Question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Total nOOb Question
|
|
|
| I have just started programing in PHP (Love it!) however I have run
into two problems! here they are.
1st One I'm sure is SIMPLE
I have two strings $stringa and $stringb
If these these two strings are DIFFERENT then I want to do X on string
a
What would the IF operator be?
My second issue seems to be more of an IE issue than a PHP issue
I work for a company that develops software for the building industry
and would like to distribute one of our software products via the
web.
here is the problem
The main file sits on my web server. We generate unique URLs for the
buyer to download the software. We also generate unique filenames and
store it in a database along with the unique URL This in essence is a
pseudo filename (i.e a filename that is unique to the user and does
NOT exist on our web server)
When the user clicks on the URL that we send him I need the PHP
script to initiate the file transfer giving the user the pseudo
filename rather than the actual filename on the server
I have everything working except for the ability to send the user the
pseudo filename! at this moment in time we are sending them the same
filename as the file sitting on our server.
Is there anyway of doing this with PHP?
Any help would much be appreciated
Edit: In my code I have tried the following
header('Content-Description: File
Transfer');
header('Content-Type: application/force-download'); //
Tells the browser to expect a download
header("Content-Transfer-Encoding: Binary"); //
Tells the browser the format of the data
header('Content-Length: ' .
filesize($realfilename)); // Tells the browser the size
of the file
header('Content-Disposition: attachment; filename=' .
basename($uniquefilename)); // Tells the browser the
name of the file
readfile($realfilename);
As you can see I am reading the original filename's properties however
using the Content-Disposition header to tell the browser the filename
to download!
For some reason I.E always recieves a 0k file...???
| |
| Kimmo Laine 2005-08-19, 4:13 pm |
| "Ace" <admin@fsworld-dot-us.no-spam.invalid> kirjoitti
viestissä:48SdnbTIcaBBnZveRVn-2A@snappydsl.net...
>I have just started programing in PHP (Love it!) however I have run
> into two problems! here they are.
>
> 1st One I'm sure is SIMPLE
>
> I have two strings $stringa and $stringb
>
> If these these two strings are DIFFERENT then I want to do X on string
> a
>
> What would the IF operator be?
if(trim($stringa) !== trim($stringb)){
// Do something.
}
A simple if($stringa != $stringb) would work too, but when using timr, you
can eliminate possible occurances of whitespace before and after the string.
I assume that you'd like to match "cat" with " cat" even though there's a
space before the second cat. If you don't want, but you need _exact_
matches, remove the trim's. A second thing is that I've used the
type-specific version of not equal operator, !==. It differs from a single
type-blind != in that it requires the types to match as well. It just adds a
tad more security to your script, although I'm not sure whether you'll be
needing it or not, concider it "just in case".
--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine <eternal.erectionN0@5P4Mgmail.com>
| |
|
| Hi,
> if(trim($stringa) !==
trim($stringb)){
> // Do something.
> } [/quote:2a022a393c]
Ahhaaa! I see the difference! Thanks I will use that operator.
On my other problem I did some research. There is nothing wrong with
my code - the problem is with Internet Explorer. It works just fine
with Firefox.
|
|
|
|
|