PHP只有在存在另一个PHP引用时才会回显?

Not sure if this is possible but what I am wanting to do is echo a html text link only if the page contains certain php code, in particular just the opening reference of 'myApi'. So if the page contains the following code:

<?php myAPI(variables); ?>

Then I would like to include this somewhere else on the page

<?php echo '<a href="http://www.website.com/">Click Here</a>'; ?>

Any help would be much appreciated, thanks :)

Set an if somewhere, and use isset to test if your API has set a specific variable or not.

if(isset($apiVariable)) {
  echo "link content...";
}

(The variable should be specific to your API, obviously.)

Update

I said "somewhere", but it's probably best to do the test logic it in a separate place than where you output the HTML. In that case, you'd need a flag for when you're ready to spit out the HTML:

isset($apiVariable) ? $apiFlag = true : $apiFlag = false;
// continue other PHP operations...


//...now your logic is finished, output HTML.
if($apiFlag) { echo "<a>Link</a>"; } 

That way, when you re-visit the page later for revision or update, your logic not all mixed up with your display.

<?php if (isset($variable)): ?>

<a href="http://www.website.com/">Click Here</a>

<?php endif; ?>

The function isset() check if the variable is set and returns a boolean. so you can use it to check if a variable exist.