1

Hi guys this is my code

<?php
  $res = shell_exec('curl  http://www.example.com');

I launched it from the terminal using this command

php script.php

and this is the output:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100  1270  100  1270    0     0   5515      0 --:--:-- --:--:-- --:--:-- 11545

I don't want to see nothing how can i do??

2
  • 1
    are you always making calls to curl? if thats the case you should be using phps implementation of curl Commented Nov 20, 2014 at 16:18
  • I must to use this way Commented Nov 20, 2014 at 21:27

2 Answers 2

1

You are seeing that output because curl outputs its current progress to STDERR.

You could solve this with a redirection if you want to ignore it:

$res = shell_exec('curl  http://www.example.com 2>/dev/null');

Or, in the shell level:

$ php script.php 2>/dev/null
Sign up to request clarification or add additional context in comments.

1 Comment

Thank thisbis the best way
0

You can use output buffering

ob_start();
$res = shell_exec('curl  http://www.example.com');
ob_end_clean();

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.