PHP echo returns with "/n/n(string)"

I'm having a problem then I trying to use the echo command from PHP scripts.

In Unity I received it on the third row.

The PHP script.

<?php
include "config.php";
echo "1";
?>

The Java script

var formText = "";
var URL = "http://localhost/test.php";
function Start() { 
   var w = WWW(URL);   yield w;    if (w.error != null) { 
      print(w.error); 
   } else { 
      print("Test ok"); 
      formText = w.data; 
      print(formText);
      w.Dispose();
      //w.Dispose(); 
   } 
} 

Anyone familiar with this problem? or maybe have a solution for it?

First, you don't need to Dispose the WWW object. It will be automatically disposed of when the variable falls out of scope.

The extra return chars aren't likely to be to do with your javascript in Unity. You probably have return characters outside your PHP tags in your php file - i.e. after the closing ?> - which are added to the output. (anything outside the php tags is printed as normal output).

What's the problem here? Unless there's something in config.php that's throwing off your output, PHP doesn't add any extra data when you echo something at all. If you echo 1, it will print 1.

If you need to, you can use the functions in the String class to strip out the two extra line breaks from the PHP script output, as well. Either replace with nothing, or grab the substring of the string, omitting the extra 's that you don't want.

You're lucky I know PHP fairly well... but please keep in mind that this is UnityAnswers not PHPAnswers. We can't answer questions pertaining specifically to other programming languages.