/    Sign up×
Community /Pin to ProfileBookmark

Return as a link

I have a function that searches a txt file. I need the return to display as a link. What would be the proper syntax for that?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Jan 22.2007 — Your function should return a string or false, if the search failed.

If the return value is not false, then could can display the value as a link. What I am trying to say is that you shouldn't be tempted into coding:[code=php]<?php
echo MyFunction();
?>[/code]


Better would be:[code=php]<?php
$MyLink = MyFunction();
if ($MyLink) {
echo "<a href='$MyLink'>.....</a>";
}
?>[/code]
Copy linkTweet thisAlerts:
@EvieauthorJan 22.2007 — My apologies, I'm trying to help a friend.

The function returns a hard drive address, I want to pull out the file name and put it on the end of a url.

like is:
[code=php]
<a href="URL_BASE/<?php {$result_from_explode} ?>">LINK</a>
[/code]


correct?
Copy linkTweet thisAlerts:
@NightShift58Jan 22.2007 — [code=php]<?php
$FULLpath = MyFunction();
if ($FULLpath) {
echo "<a href='URL_BASE/" . basename($FULLpath) . "'>LINK</a>";
}
?>[/code]
×

Success!

Help @Evie 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.20,
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,
)...