0

I am calling my rest with CURL php and setting response header like:

 header('Status',true,422);

and when printing status I get 422.

but when I set header like:

 header('Status',true,440);

I get 500 code in response.

I don't know why is it happening.

Please help me in this issue.

3
  • You have to make sure nothing is returned before the "header" statement. Are you sure 440 is valid for all web servers? I think it has something to do with microsoft. Commented Feb 2, 2015 at 14:21
  • @inneedofhelp I am not sure about it weather 440 is valid for all the services or not.How can I know about it? Commented Feb 2, 2015 at 14:40
  • I would suggest googling it, sorry I don't have the answer ready. Commented Feb 2, 2015 at 14:45

1 Answer 1

2

You shouldn't return HTTP Code headers in this way. There is dedicated function: http://php.net/manual/en/function.http-response-code.php

<?php
http_response_code(422);
http_response_code(440);
?>

Additionally, make sure you don't return anything (e.g. by echo) before calling these commands.

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

1 Comment

@y221 thanks for resposne. but 440 is not working . Is there is any problem with YII framework with this code or nay other reason?

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.