dannybrazil Posted March 27, 2008 Share Posted March 27, 2008 hello can some one help me with this one : $email=$row['email']; echo '<a href="mailto:$email ">'.$email'</a>'; i want that the LINK will send as an e-mail to word express or something that the user uses i know it wrong cus it doesnt work ....someone ? Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/ Share on other sites More sharing options...
MadTechie Posted March 27, 2008 Share Posted March 27, 2008 try this $email=$row['email']; echo '<a href="mailto:$email">'.$email.'</a>'; removed a space and added a dot (.) Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502191 Share on other sites More sharing options...
dannybrazil Posted March 27, 2008 Author Share Posted March 27, 2008 cool works one more : how can i add an automatic SUBJECT that will appear in the e-mail editor of the user ? if i want the subject to be information from my DB (lets say title) $email=$row['email']; $subject=$row['title']; echo '<a href="mailto:$email?subject=$subject">'.$email.'</a>'; Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502306 Share on other sites More sharing options...
MadTechie Posted March 27, 2008 Share Posted March 27, 2008 that looks okay.. maybe use urlencode $email=$row['email']; $subject=urlencode($row['title']); echo '<a href="mailto:$email?subject=$subject">'.$email.'</a>'; Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502314 Share on other sites More sharing options...
discomatt Posted March 27, 2008 Share Posted March 27, 2008 Also, I'm not sure how it's working with this echo '<a href="mailto:$email?subject=$subject">'.$email.'</a>'; Variables are not parsed within single quotes, as far as i know... it should be this: echo '<a href="mailto:'.$email.'?subject='.$subject.'">'.$email.'</a>'; Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502316 Share on other sites More sharing options...
MadTechie Posted March 27, 2008 Share Posted March 27, 2008 oooops i overlooked that yes it will not parse in single quotes just excape the double quotes like this $email=$row['email']; $subject=urlencode($row['title']); echo "<a href=\"mailto:$email?subject=$subject\">$email</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502322 Share on other sites More sharing options...
discomatt Posted March 27, 2008 Share Posted March 27, 2008 IMO using single quotes is the better way. I like to avoid using double quotes at all costs for efficiency reasons... Why parse strings when the majority of the content in the string doesn't need to be parsed? Isolating variables from the string is, in my opinion, the better way to do it. Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502330 Share on other sites More sharing options...
MadTechie Posted March 27, 2008 Share Posted March 27, 2008 True, but php 5 is smarter than php 3 when it comes to quotes if you do 2 million iterations of echo 'Test '.$avar; echo "Test $avar"; your save yourself 0.6 of a second.. personally i code quicker with double quotes and the code is smaller.. thus less memory so to sum up.. i perfer double quotes Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502342 Share on other sites More sharing options...
discomatt Posted March 27, 2008 Share Posted March 27, 2008 I'd love to see the test used to get those numbers. I have a hard time believing that a loose syntax can be faster than a stricter one Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502357 Share on other sites More sharing options...
MadTechie Posted March 27, 2008 Share Posted March 27, 2008 simple test <?php define ('MAX',2000000); function f1() { for($i=0;$i<MAX; $i++) { $c = "test $i"; } } function f2() { for($i=0;$i<MAX; $i++) { $c = 'test ' . $i; } } $t1 = microtime(true); f1(); $timed1 = (microtime(true) - $t1); echo "Time 1: $timed1 <br>"; $t2 = microtime(true); f2(); $timed2 = (microtime(true) - $t2); echo "Time 2: $timed2 <br>"; echo "Time 2 is faster by: ".($timed1-$timed2)." over ".MAX." iterations "; ?> my results Time 1: 2.3318119049072 Time 2: 2.0601480007172 Time 2 is faster by: 0.27166390419006 over 2000000 iterations edit: which isn't even 0.6 but 0.3 (rounded up) last test was in php5 now in php 5.2 Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502367 Share on other sites More sharing options...
discomatt Posted March 27, 2008 Share Posted March 27, 2008 Weird. I performed a more fair test (alternating which was called first, clearing memory, ect) and found that over many iterations of 1000000 loops, they perform about the same. Around 60% of the time, single quotes were faster, and the remaining 40, double was faster. This is surprising, as i expected single to be more than 60% Also - as I increased the amount of declarations per loop and the complexity of the declaration (100 declarations per loop, only looping 10000 times) single started to show more favourable results, but it was still not as significant as I thought (68% to 32% over 100 runs) Still, i find it good practice to isolate variables from strings Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502423 Share on other sites More sharing options...
BlueSkyIS Posted March 27, 2008 Share Posted March 27, 2008 personally i code quicker with double quotes and the code is smaller.. thus less memory so to sum up.. i perfer double quotes Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502427 Share on other sites More sharing options...
MadTechie Posted March 27, 2008 Share Posted March 27, 2008 Well in php3 i was good pratice but now days i don't think it really matters that much.. its the same with most things Security vs Usability Speed vs Memory Memory vs storage etc etc etc etc even if someone found the perfect match ups and build a system of rules.. your then have the problem of long term vs short term cost of the system as a whole, as it would probably take longer to write the system. ... okay this isn't the best place for these posts, dannybrazil head will probably explode..lol i'll let you have the final say if you like Quote Link to comment https://forums.phpfreaks.com/topic/98162-e-mail-link/#findComment-502435 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.