2

I'm having a problem with these lines of code:

<a class="button" href="javascript:unhide('<?php  $a; ?>')">Expand / Hide</a>
<?php echo substr($f2, 0, 400);?><div id="<?php $a; ?>" class = "hidden"><?php echo substr($f2, 400, 5000);?></div>

If the variable $a is replaced with plaintext then the code works, however when it links to a string variable it does not.

The example below shows an working version of the code (however because of the code's purpose I need to use a varaible):

<a class="button" href="javascript:unhide('exampleword')">Expand / Hide</a>
<?php echo substr($f2, 0, 400);?><div id="exampleword" class = "hidden"><?php echo substr($f2, 400, 5000);?>

Any ideas?

1 Answer 1

7

Replace

<?php  $a; ?>

with

<?php echo $a; ?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.