CodeIgniter Forums
Issue with Codeignter3 with network calls functions - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Issue with Codeignter3 with network calls functions (/showthread.php?tid=70678)

Pages: 1 2


Issue with Codeignter3 with network calls functions - peter2015 - 05-13-2018

Hello,

I haver tried both functions on CI2 and CI3 and found there is an issue with CI3.
On welcome controller I have added index2 method and execute it.
public function index()
{
$this->load->view('welcome_message');
}

public function index2()
{
for($j=0;$j<=10;$j++){
echo file_get_contents("https://google.com");
}
}
While the index2 is executing on CI3, I wasn't able to access any other function on the controller unless it finishes the execution, When I access index() as example the browser keep waiting until the execution of index2 finishes the it load the page.

I tried same to do the same thing on CI2 and it worked without any issue.

Could you please check what could be the issue.
Thanks


RE: Issue with Codeignter3 with network calls functions - peter2015 - 05-15-2018

Hello,

Any comment ??


RE: Issue with Codeignter3 with network calls functions - Paradinight - 05-15-2018

(05-15-2018, 06:25 AM)peter2015 Wrote: Hello,

Any comment ??

PHP Code:
while (ob_get_level() > 0)
{
    
ob_end_flush();
}
ob_implicit_flush(TRUE);

for(
$j=0;$j<=10;$j++){
    echo 
file_get_contents("https://google.com");


http://php.net/manual/en/function.ob-implicit-flush.php


RE: Issue with Codeignter3 with network calls functions - peter2015 - 05-15-2018

Hi Paradinight ,

Thanks for the reply, I tried the way you mentioned but it didn't work!


RE: Issue with Codeignter3 with network calls functions - InsiteFX - 05-16-2018

I always do this first when using those commands.

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

ob_start();

class 
YourClass
{



Give that a try and see if it helps.


RE: Issue with Codeignter3 with network calls functions - peter2015 - 05-16-2018

(05-16-2018, 03:13 AM)InsiteFX Wrote: I always do this first when using those commands.

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

ob_start();

class 
YourClass
{



Give that a try and see if it helps.

Thanks, this worked ! ... I tried to implement it in other function which has a curl, file_get_content, get_headers It didn't work .

Do you have any idea ?

Thanks again.


RE: Issue with Codeignter3 with network calls functions - InsiteFX - 05-17-2018

(05-16-2018, 11:27 PM)peter2015 Wrote:
(05-16-2018, 03:13 AM)InsiteFX Wrote: I always do this first when using those commands.

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

ob_start();

class 
YourClass
{



Give that a try and see if it helps.

Thanks, this worked ! ... I tried to implement it in other function which has a curl, file_get_content, get_headers It didn't work .

Do you have any idea ?

Thanks again.

You have Private Messaging turned off so have to answer here.

Please read these two articles on output buffering.

PHP Manual - ob_start

Everything About Output Buffering in PHP

Hope that helps.


RE: Issue with Codeignter3 with network calls functions - peter2015 - 05-17-2018

Thanks for your continuous support, would you please if you don't mind to have a loot at the code I sent you in private message.

Thanks,


RE: Issue with Codeignter3 with network calls functions - peter2015 - 05-20-2018

Can anyone please help me out.

thanks,


RE: Issue with Codeignter3 with network calls functions - InsiteFX - 05-20-2018

Here is another one to read...

PHP file_get_contents not working

You do know that if you search with Google you would find your answers.