0

I'm trying to modify an existing html which is output using echo.

<form action="/" id="searchForm" method="post">

I want to replace the "/" with $targetHost.

I can't seem to get the syntax correct.

Any help is much appreciated.

1 Answer 1

1
<form action="<?= $targetHost ?>" id="searchForm" method="post">

<?= $targetHost ?> is a shorthand for <?php echo $targetHost ?>

Sign up to request clarification or add additional context in comments.

2 Comments

I tried that using this snippet: <?php $targetHost="/mobile/index.php"; $matrix ='<form action="<?= $targetHost ?>" id="searchForm" method="post">'; echo $matrix .'<br/>'; The output looks like this: <form action="<?= $targetHost ?>" id="searchForm" method="post"><br/>
if your html is wrapped in a string then you don't need to worry about the <?= ?>. Just use regular string concatenation. <?php $targetHost="/mobile/index.php"; $matrix = '<form action=' . $targetHost . ' id="searchForm" method="POST"><p>Hello World</p></form><br/>'; echo $matrix; ?>

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.