0

I'm creating an auto documenter for our APIs. Part of the documentation will be a code example -- pretty much just shows the array of data that should be passed to the API and the curl commands to execute it.

I have this mostly working, but the opening <?php is causing me problems. The best thing I've found is to do

$code_example = "\n<\?php ... ";

I don't have this issue in php 5.5, but our API servers (where this will be running) are on 5.3 at the time being. I don't really like escaping the tag, but it might be the only way I can do it.

Any ideas?

Thanks!

2
  • 1
    What is the problem and how are you handling the string? Commented Feb 17, 2016 at 15:07
  • @Devon I'm not sure what you mean. I have a script that generates a string which is a PHP file. This gets stored into our API documentation database, but I either have to escape the opening tag, or the first couple lines get cut off Commented Feb 17, 2016 at 15:09

1 Answer 1

1

Your question problem is not clear. But maybe you want print code to document. Try convert your code_example text with function htmlspecialchar before print

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.