Page 1 of 1

capture filename and email it: help

Posted: Wed Jan 15, 2003 9:56 am
by dbonneville
Hi: I know very little about PHP, but do know code (actionscript, javascript, ColdFusion).

I'm trying to get the name of a file and send it to myself if someone clicks it. Right now, I'm using a little PHP script to capture the browser type and put that in a message using the mail commands.

What call would I use to get the name of the page clicked? And how do I concatenate that information into the body of my message? How do I concatnate other variables I have access to into the message body variable?

Thanks in advance for any help or suggestions.

Doug Bonneville
http://www.bonfx.com

Posted: Wed Jan 15, 2003 1:29 pm
by volka
$_SERVER['PHP_SELF'] contains the name of the current script (as virtual path), in older versions or with register_globals=On it's stored in $PHP_SELF.
String concatenation is done via

Code: Select all

$result = $string1 . ' <-> '.$string2;
http://www.php.net/manual/en/reserved.variables.php
http://www.php.net/manual/en/language.operators.string.php

Posted: Thu Jan 16, 2003 9:27 am
by dbonneville
Is '<->' the concatentation call? If I want to put a few string items together into one var and dump that into the body of the email, would that be:

$myMailMessage = $first.'<->'.$second.'<->'$third;

Do I need spaces after the string name before the period, and also after the period but before the $ of the next var name?

Thanks!

Doug

Posted: Thu Jan 16, 2003 9:32 am
by laserlight
the concatenation uses the dot operator, as in

Code: Select all

$str1 = $str2 . $str3;
The '<->' is string some string separator so you can differentiate the original strings when they are stored as a single string.

Posted: Thu Jan 16, 2003 11:22 am
by volka
sorry, I just wanted to show that it doesn't matter wether you concatenate variables or literals

Code: Select all

$s1 = 'string concatenation';
$s2 = 'easy';
$out = $s1 . ' is ' . $s2;
echo $out;
You may concatenate almost any type (because almost any type has a string representation ... a more or less reasonable ;) )

Code: Select all

$a = 1;
$b = 2;
$out = $a . '+' . $b . '=' . ($a+$b);
echo $out;

p.s.: a more or less reasonable string representation means e.g.

Code: Select all

$arr = array(1,2,3,4);
echo $arr;
which will print Array because the string representation of any array is Array