0

I need some help to put a simple php tag in this code

$return.="<form method='post' action='#'><input type='submit' value=''><input type='hidden' name='task'></form>";

I need to put the php - <?php echo $htmlString; ?> - in the first input tag

Can somebody help please?

Thanks

1
  • where exactly do you want to insert it? As value in Submit button? Commented Dec 24, 2011 at 22:09

3 Answers 3

2
 $return.="<form method='post' action='#'><input type='submit' value='$htmlString'><input type='hidden' name='task'></form>";
Sign up to request clarification or add additional context in comments.

4 Comments

thanks for the quick reply, but I need it to be like I wrote exactly "<?php echo $htmlString; ?>" because I have one more input and there I will put <?php echo CbText::_('CONFIRM');?> (this is for multilingual translate) ... so I basicaly need the php code "<?php echo CbText::_('CONFIRM');?>" in that input.. I tried to put it in different ways but it always gives me some error .. can you help please?
I'm not sure I follow, or if I do, if it is a smart move. You'll end up with a PHP String with that exact text in it. What will you do then? save it as a .php file? Run it trough EVAL? Because if you ECHO it, it will not be parsed again in a default environment!
Hmm.. I'm not too good in this stuff sorry can't explain well, but the code from Echo will go in a file (where all the translations are) and I'm writing the code from echo which for example is CONFIRM , and give it a value like this CONFIRM=CONFERME (depends on file, each file one language)..
Please don't bother any more, Virendra helped with the code, it's like this - $return.="<form method='post' action='#'><input type='submit' value='" . CbText::_('CONFIRM') . "'><input type='hidden' name='task'></form>";
0

If you want to insert it as value to submit button here is the solution.

$return.="<form method='post' action='#'><input type='submit' value='$htmlString'><input type='hidden' name='task'></form>";

Update: Use the following code: as you want to use the variable CbText::_('CONFIRM').

$return.="<form method='post' action='#'><input type='submit' value='" . CbText::_('CONFIRM') . "'><input type='hidden' name='task'></form>";

3 Comments

thanks for the quick reply, but I need it to be like I wrote exactly "<?php echo $htmlString; ?>" because I have one more input and there I will put <?php echo CbText::_('CONFIRM');?> (this is for multilingual translate) ... so I basicaly need the php code "<?php echo CbText::_('CONFIRM');?>" in that input.. I tried to put it in different ways but it always gives me some error .. can you help please?
use the following code: $return.="<form method='post' action='#'><input type='submit' value='" . CbText::_('CONFIRM') . "'><input type='hidden' name='task'></form>";
Awesome! I'll update my answer as per your new requirements. Merry Christmas!!
0

There are two ways to do this:

  • You can print HTML code conditionally with PHP using this syntax:

    <?php
    
    // Your code
    
    ?>
    
    <form method='post' action='#'>
      <input type='submit' value='<?php echo $htmlString; ?>'>
      <input type='hidden' name='task'>
    </form>
    
    <?php
    
    // Your code
    
    ?>
    
  • Or just by string concatenation:

    $return .= "<form method='post' action='#'>";
    $return .= "<input type='submit' value='$htmlString'>";
    $return .= "<input type='hidden' name='task'></form>";
    

1 Comment

thanks for the quick reply, but I need it to be like I wrote exactly "<?php echo $htmlString; ?>" because I have one more input and there I will put <?php echo CbText::_('CONFIRM');?> (this is for multilingual translate) ... so I basicaly need the php code "<?php echo CbText::_('CONFIRM');?>" in that input.. I tried to put it in different ways but it always gives me some error .. can you help please?

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.