Support the ongoing development of Laravel.io →
Blade Architecture

Take this (non) blade script list.blade.php :

<?php
error_log( print_r( "START" , true ) );

global $i;

for ( $a = 0 ; $a < 3 ; $a++ ) {
	$j = @(int)$i;

	error_log( print_r( $j , true ) );
	echo $j;

	$i = $j + 1 ;
}

error_log( print_r( "STOP" , true ) );

The expected result should be 012 but the output is 345 !

If you check your server error logs, you can see this :

START
0
1
2
STOP
START
3
4
5
STOP

Therefore the template is ran a first time without outputting anything and it is ran a second time and the output is then sent.

I use an updated Laravel 4.2 version. It is not really a problem but when each parsed row is requesting heavy computing task, the load time is just X2.

Do you think it is a bug or is it a normal behaviour ?

Is there a way to avoid some executions in the template on the first launch (dry run) ?

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

potsky potsky Joined 29 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.