Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7516875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:16:22+00:00 2026-05-30T01:16:22+00:00

when I enter in code like this: <p>Hello <? echo $name; ?>, How are

  • 0

when I enter in code like this:

<p>Hello <? echo $name; ?>, How are you?</p>

It prints:

<p>Hello <!--? echo $name; ?-->, How are you?</p>

As a comment. I have it in a file called base.js with this code:

function showName() {
   document.getElementById("name").innerHTML = "<p>Hello <? echo $name; ?>, How are you?</p>";
}

So I embed the .js file like so:

<script type="text/javascript" src="base.js"></script>

So, after it changes the <p id="name"></p> I get:

<p id="name">Hello <!--? echo $name; ?-->, How are you?</p>

I had the code in the .php file, and it seemed to work fine. Now that I have it in a separate base.js file, it ceases to function. Help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:16:24+00:00Added an answer on May 30, 2026 at 1:16 am

    That is because it is no longer php.

    Change to

    <script type="text/javascript" src="base.php"></script>
    
    and have a 
    <?php header("content-type:text/javascript"); 
    $name = "...";
    ?>
    
    function showName() {
       document.getElementById("name").innerHTML = "<p>Hello <?php echo $name; ?>, How are you?</p>";
    }
    

    Or

    change to

    function showName(name) {
       document.getElementById("name").innerHTML = "<p>Hello "+name+", How are you?</p>";
    }
    

    and in the php file have

    <script>
    // using json_encode to make the string safe for script injection. 
    // Still needs quotes for a single string
    showName("<?php echo json_encode($name); ?>");
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an email template where the user can enter text like this: Hello
I have a form like this: <form id=form_main name=form_main action=/search/ target=iframe001 method=get onSubmit=reset_and_subm();> Enter
I have this code in Python inputted = input(Enter in something: ) print(Input is
When we use Javascript prompt Box something like this var ur_name = prompt(Enter Name);
I saw some code, html form code which looks like this: <form name=form1 method=post
I have a code like this. <html> <head> <title>Captcha With Refresh Feature</title> <script src=jquery.js
There is my problem : enter code here I have a table called test
enter code here I have a table on SQL server 2005 with bigint primary
enter code here Hi All, I have a simple windows service application that connects
I have a very small form where a user can enter their zip code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.