Jump to content

e-mail link


dannybrazil

Recommended Posts

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>';

Link to comment
Share on other sites

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>';

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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  ;)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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 :)

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.