Sorry, Mohammad, I was gone for a few days. I am not sure what you want to do. I will comment on some of what you have said and hopefully, figure out what you want to do.
Code on the server, meaning PHP code, can not be seen by others. It is safe and secure that way so that others can not steal your code. That is how it was designed and works well.
Code on the browser, meaning Javascript, can be seen by all users and since it runs on the user’s system, it can use anything on their computer thru Javascript calls. This is NOT secured at all and therfore should be used with caution.
Now, you said you want to show code, but, not let users use it. That makes little sense to me. Either you want to allow users to see and use code or you do not want them to see it and use it. You can not give out displays of code and still protect it. Make no sense to me. Unless I am not understanding you do to our language differences. Please try to explain what you want to do. Remember that Javascript is not secure and any user can see it and alter it. PHP is secure and safe as it hides from the browser.