473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Seems like "echo" isn't working (yeah, right)

Of course "echo" is working, but I've got a case where php doesn't
seem to be sending out the result of an "echo." I'm probably doing
something wrong, but I can't see it.

I've got the following code on IIS 5.0, Win 2000, PHP 4.3.3, in file
LH_Svc.php:

<?php
$resp = "<response>\r\n";
$respLen = strlen ($resp);
header ("Content-Type: text/xml\r\n");
header ("Content-Length: $respLen\r\n\r\n");
echo ($resp);
exit;
?>

In a separate command window, I run the following php script:
<?php
$server = "localhost";
$url = "/earn/LH_Svc.php";
$port = 80;
// open socket
$fp = fsockopen($server, $port);
if (!$fp) {
echo "Could not open socket";
}
else {
$postData = "<test>";
$dataLen = strlen ($postData);

$postHeader = "POST $url HTTP/1.0\r\n";
$postHeader .= "User-Agent: PHP-MJF Client\r\n";
$postHeader .= "Content-Type: text/xml\r\n";
$postHeader .= "Content-Length: $dataLen\n";
$postHeader .= "\r\n"; // required extra blank line

echo ($postHeader);
echo ($postData);
echo ("\n====================\n");

fwrite ($fp, $postHeader);
fwrite ($fp, $postData);

$getResponse = fread ($fp, 14096);
fclose ($fp);

echo "Length of response is " . strlen ($getResponse) . "\r\n";
echo $getResponse;
echo "=====================\n";
}
?>

Here's what I get printed out on the command window when I run it:

D:\EarnApps>d:\php\php-4.3.3-win32\cli\php.exe post.cli
POST /earn/LH_Svc.php HTTP/1.0
User-Agent: PHP-MJF Client
Content-Type: text/xml
Content-Length: 6
<test>
====================
Length of response is 152
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Wed, 19 Nov 2003 20:39:02 GMT
X-Powered-By: PHP/4.3.3
Content-Type: text/xml
Content-Length: 12
=====================

The first file is sending the HTTP headers, and should also then send
the string "<response>\r\n". However, I never get that string returned
to the command window. I see the HTTP headers, but not the <response>.
This works under Apache, running on a Linux box.

Any ideas?

Thanks.
Jul 17 '05 #1
3 2656
go********@MJFlanagan.com (Michael Flanagan) wrote in message news:<96**************************@posting.google. com>...
Of course "echo" is working, but I've got a case where php doesn't
seem to be sending out the result of an "echo." I'm probably doing
something wrong, but I can't see it.

I've got the following code on IIS 5.0, Win 2000, PHP 4.3.3, in file
LH_Svc.php:

<?php
$resp = "<response>\r\n";
$respLen = strlen ($resp);
header ("Content-Type: text/xml\r\n");

^^^^^

You don't need to add \r\n

---
"One who mix sports and patriotism is a barbarian"
Email: rrjanbiah-at-Y!com
Jul 17 '05 #2
Thanks for the suggestion. I took out the chars you suggested--no
change. I then added some newline echos after the last header
call--still no change. BTW, this code works on Apache/Linux.

??

Michael

ng**********@rediffmail.com (R. Rajesh Jeba Anbiah) wrote in message news:<ab**************************@posting.google. com>...
go********@MJFlanagan.com (Michael Flanagan) wrote in message news:<96**************************@posting.google. com>...
Of course "echo" is working, but I've got a case where php doesn't
seem to be sending out the result of an "echo." I'm probably doing
something wrong, but I can't see it.

I've got the following code on IIS 5.0, Win 2000, PHP 4.3.3, in file
LH_Svc.php:

<?php
$resp = "<response>\r\n";
$respLen = strlen ($resp);
header ("Content-Type: text/xml\r\n");

^^^^^

You don't need to add \r\n

---
"One who mix sports and patriotism is a barbarian"
Email: rrjanbiah-at-Y!com

Jul 17 '05 #3
The problem seems to be that I cannot simply get the response with this:

$getResponse = fread($fp, 1024);

I should put that in a 'while' loop until I get EOF or no error.

Michael

go********@MJFlanagan.com (Michael Flanagan) wrote in message news:<96**************************@posting.google. com>...
Thanks for the suggestion. I took out the chars you suggested--no
change. I then added some newline echos after the last header
call--still no change. BTW, this code works on Apache/Linux.

??

Michael

ng**********@rediffmail.com (R. Rajesh Jeba Anbiah) wrote in message news:<ab**************************@posting.google. com>...
go********@MJFlanagan.com (Michael Flanagan) wrote in message news:<96**************************@posting.google. com>...
Of course "echo" is working, but I've got a case where php doesn't
seem to be sending out the result of an "echo." I'm probably doing
something wrong, but I can't see it.

I've got the following code on IIS 5.0, Win 2000, PHP 4.3.3, in file
LH_Svc.php:

<?php
$resp = "<response>\r\n";
$respLen = strlen ($resp);
header ("Content-Type: text/xml\r\n");

^^^^^

You don't need to add \r\n

---
"One who mix sports and patriotism is a barbarian"
Email: rrjanbiah-at-Y!com

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jonny T | last post by:
hi, i want to echo the string '<?php' in a php script like : echo "<?php"; but when i try nothing gets displayed ... if I use echo "<\?php";
2
by: brianj | last post by:
Running php4.3.6 What i'm trying to do is exactly like the weather channell site when you click in the zip code box the text dissapears and you are free to type your zip. I can make it work by...
6
by: Fabrice Régnier | last post by:
Hi ;) Everything is in the title. the prob is "boo" is displayed ! Can you believe it ? Thanx for anyone who can help me. fabrice.
1
by: Ennio-Sr | last post by:
Hi all! I'm writing a script that presents the user with a numbered lines menu, each line corresponding to a <case n> which executes a psql command. As the psql-commands are very similar to each...
2
by: funkyj | last post by:
I've been googling around trying to find the answer to this question but all I've managed to turn up is a 2 year old post of someone else asking the same question (no answer though). ...
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
2
by: eholz1 | last post by:
Hello Group, does this make sense?? I have some java code that responds to keypress events (the arrow keys) <script language="javascript"> <!-- function keypressed(e) {
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.