0

I have a PHP socket connection. I send a request and receive its response. The response is in xml format and contains '<'. I want to concatenate strings and build one string of complete response. But when I put '<' at the beginning of string the whole string becomes null:

$s1 = 'hello';
$s2 = '<';
$s = $s2.$s1;
echo 's1: '.$s1.' s2: '.$s2.' s: '.$s;

output:
s1: hello s2: < s: 

What should I do?

3
  • your code is working and giving same result. what's your problem then? Commented May 27, 2015 at 7:09
  • 1
    Use "View source" in your web browser to verify the < is sent correctly to the browser, then learn that a web browser specifically looks for a < character when it receives what it is told is html markup Commented May 27, 2015 at 7:09
  • I want the result to be s: <hello instead of empty string @anantkumarsingh Commented May 27, 2015 at 7:14

1 Answer 1

2

These is problem of TAGs that being skipped by Web Browser to display. You can display by converting '<' to "&lt".

PHP has built-in functions for such problem,

String functions

Search for 'HTML' in this page, you will get 4-5 functions that will help you.

Hope that helps !!

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

Comments

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.