Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Print 1 & Exit in My template

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
i-litovan
Smarty Rookie


Joined: 03 Aug 2013
Posts: 13

PostPosted: Tue Sep 17, 2013 6:02 am    Post subject: Print 1 & Exit in My template Reply with quote

Hi.

I have this template:

Code:


<h1>Header</hh1>
next template code
next template code
next template code
next template code

   {php}
   print 1111;
   exit();
   {/php}

next template code
next template code
next template code
next template code



I run a Smarty and get:
<h1>Header</hh1>
next template code
next template code
next template code
next template code
1111


How can I get only 1111?

--
Ivan/.
[/code]
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Sep 17, 2013 6:42 pm    Post subject: Reply with quote

your script exits right after printing 1111.

exit();

the exit() function ceases the execution of PHP altogether, not just exiting the php script you are in.

and FWIW, don't use {php} tags at all if possible.
Back to top
View user's profile Send private message Visit poster's website
i-litovan
Smarty Rookie


Joined: 03 Aug 2013
Posts: 13

PostPosted: Sat Sep 21, 2013 12:06 pm    Post subject: Reply with quote

mohrt wrote:
your script exits right after printing 1111.

exit();

the exit() function ceases the execution of PHP altogether, not just exiting the php script you are in.

and FWIW, don't use {php} tags at all if possible.


You are right ...
Thenk you.
Back to top
View user's profile Send private message
sophiaMia
Smarty n00b


Joined: 06 Sep 2014
Posts: 1

PostPosted: Sat Sep 06, 2014 6:08 am    Post subject: Reply with quote

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

######################### We start with some black magic to print on failure.

# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)

BEGIN { $| = 1; print "1..16\n"; }
END {print "not ok " . ++$testid . "\n" unless $loaded;}

use HTML::Template::Extension;
use HTML::Template::Extension::ObjBase;


# Create test obj with support for doing nothing but standart:=)
# DON'T USE DO_NOTHING...IT'S ONLY AN BASE EXTENSION MODULE FOR CREATING NEW ONES
my $comp = new HTML::Template::Extension(
filename => 'templates/standard.tmpl',
plugins=>["DO_NOTHING"],
);

$comp->param('test' => "It works!!!");
$_ = $comp->output;
print;

if (m/It works/) {
print "\nok " . ++$testid . "\n";
} else {
exit;
}



imprenta online
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Sep 30, 2014 1:30 pm    Post subject: Reply with quote

Is there a "report" button on this forum?…
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP