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 8635809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:03:59+00:00 2026-06-12T10:03:59+00:00

Need some help to add PHP into HTML. I am trying to embed PHP

  • 0

Need some help to add PHP into HTML. I am trying to embed PHP code snippet in HTML however output is showing the snippet itself in the text box instead of evaluating it.

In HTML (register.php), added the below lines of code

<tr>
    <td>
        <?php utils::addControl('Name','label'); ?>
    </td>
    <td>
        <?php utils::addControl('username','text'); ?>
    </td>
</tr>

Here is the source of utils::addControl()

    public function addControl($ctlName, $type) {

    switch ($type) {
        case 'text':
            echo <<<EOT
            <input type='text' name='$ctlName' value='&lt?php echo htmlspecialchars($ctlName); ?&gt'>
   EOT;
            break;
        case 'label':
            echo "<label for id='lbl$ctlName'>$ctlName</label>";
            break;
    }

Output is showing <?php echo htmlspecialchars(username); ?> in the text box.

What should be done in order to get the PHP snippet evaluated properly. TIA.

  • 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-06-12T10:04:00+00:00Added an answer on June 12, 2026 at 10:04 am

    Servers are typically only configured for a single pass over a script while looking for PHP…

    Source → PHP → Output
    

    Not a double pass:

    Source → PHP → PHP → Output
    

    If it did perform a double pass then you would have to jump through hoops if you wanted to include the sequence <?php in the output (or even <? if short tags were turned on).

    Write your PHP so it generates that output you want in the first place, don’t try to generate PHP from PHP.

    $htmlCtrlName = htmlspecialchars($ctlName);
    echo "<input type='text' name='$htmlCtlName' value='$htmlCtrlName'>"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help structuring my php. I am trying to get 3 different
I'm trying to add some functionality from a plugin I have made into a
I'm a pdo newbie and need to prepare and execute some php/pdo code: This
i need some help from the experts. I have some rewrite rules: post.php go
I need some help with jQuery uploadify . When uploading, I want to add
I have a excel i need to add some more sheets into the excel
I need some help to figure out how to add multiple fields, on a
I'm trying to add a php string to some javascript: document.getElementById(button).value = mygetrequest.responseText; basically
I need some help doing the following. I am trying to import a list
Need some help... I have jasperserver 4.1 installed on my ubuntu. It runs via

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.