1

I want to put my global variable into echo code in php. My code is below.

<?php
global $result;

code { 
 ...
  }

$result;
//중첩검색&결과내 검색 폼 만들기
echo "<form class=\"category 2\" name=\"search\" action=\"display.php\" onsubmit=\"return validateForm()\" method=\"get\">     
Input: <input type=\"text\" name=\"search\" id=\"qstra\" onkeyup=\"showUsera()\" > 
 // Next line is something wrong!!!!!!!!!!!!!!!!!!!!!!!!!!
<input type=\"text\" name=\""?><?php $result ?><?php "\" id=\"pstra\" onkeyup=\"showUsera()\" > 
***//I want to have name = $result from global.*** 
</form>
<div id=\"hint1\"><b>information will be listed here.</b></div>";

?> 

I am a weak php programmer. Please give me a piece of advice.

Drohjho
  • 71
  • 9
  • Since you are echoing a string, read about string concatenation. You will have something like: echo 'blablabla' . $result . 'blablabla' Reference: https://stackoverflow.com/questions/8336858/how-to-combine-two-strings-together-in-php . – Samuil Petrov May 02 '18 at 05:52
  • Yeah. But my echoing code include html tag. and Attribute's value has double quotation, so excaping double quotation and inserting php variable is conflicting. So i want that help/ – Drohjho May 02 '18 at 05:57
  • 2
    You can use single quotation as your main in PHP and then you won't need to escape the double quotes for attribute values. – Samuil Petrov May 02 '18 at 05:58

1 Answers1

1

Use php string concatenation

<input type=\"text\" value=".$result." name=".$result." id=\"pstra\" onkeyup=\"showUsera()\" 
Rp9
  • 1,955
  • 2
  • 23
  • 31