Welcome Guest, Not a member yet? Register   Sign In
Issue with Codeignter3 with network calls functions
#1
Exclamation 

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
Reply
#2

Hello,

Any comment ??
Reply
#3

(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
Reply
#4

Hi Paradinight ,

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

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(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.
Reply
#7

(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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#8

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,
Reply
#9

Can anyone please help me out.

thanks,
Reply
#10

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB