/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] how to create a link in php ?

Yeah, it is a shame to ask but I do not know and do not find … How can I define a link to a string so that the string is displayed and people can click to access mysite.com?

thanks again and again !

patrick

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyOct 05.2006 — Well your question is a little hard to follow, but do you understand what PHP is and what HTML is. PHP processes certain functions and requests on the server, then echos HTML code out to the browser. So a link written in PHP would still actually be a hyperlink coded in HTML. You would only need PHP to create a link if the link was a variable and would be changed, example:[code=php]<?
$linkvar = "mysite.com";
echo '<p><a href="'.$linkvar.'">Link</a>';
?>[/code]


If that doesn't make sense then your going to have to explain your querie better so that we can assist.
Copy linkTweet thisAlerts:
@patimagesauthorOct 05.2006 — I know my knowledge is limited and I must start to piss of people with all my questions but be sure that I learn fast with you guys ! And by the way, you perfectly answered my question !

THANKS !!!!!!!!!!

patrick
Copy linkTweet thisAlerts:
@patimagesauthorOct 05.2006 — Oups... little problem here : what an I doing wrong ?
echo "<tr style='color: #ffff00'><td width=70%><a href="'.$linkvar.'">$t</a></td><td>$ss</td><td>$se</td><td>$l</td></tr>n";[/QUOTE]
Copy linkTweet thisAlerts:
@pcthugOct 05.2006 — Try:[code=php]
echo "<tr style='color: #ffff00'><td width=70%><a href="$linkvar">$t</a></td><td>$ss</td><td>$se</td><td>$l</td></tr>n";
[/code]


You were closing the original opening double-quote, then reopening a new string within single-quote without placing a . or , character within the echo statement; this was causing a T_CONSTANT_ENCAPSED_STRING error.

The syntax I think you were trying to replicate was:
[code=php]
echo "<tr style='color: #ffff00'><td width=70%><a href='".$linkvar."'>$t</a></td><td>$ss</td><td>$se</td><td>$l</td></tr>n";[/code]
Which would have been valid, although as you are using a double-quote string, variables may be referenced within the string. If you are unsure whether they will be parsed properly, enclose them within {} style parentheses. Eg:
[code=php]
echo "string{$variable}string";
[/code]
×

Success!

Help @patimages spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...