capture filename and email it: help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dbonneville
Forum Newbie
Posts: 2
Joined: Wed Jan 15, 2003 9:56 am

capture filename and email it: help

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
dbonneville
Forum Newbie
Posts: 2
Joined: Wed Jan 15, 2003 9:56 am

Post 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
laserlight
Forum Commoner
Posts: 28
Joined: Wed Jan 01, 2003 6:41 am

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
Post Reply