-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyphp.php
More file actions
101 lines (77 loc) · 2.48 KB
/
myphp.php
File metadata and controls
101 lines (77 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* Example Application
*
* @package Example-application
*/
require '../libs/Smarty.class.php';
$smarty = new Smarty;
// chapter 14
// add directory where config files are stored
// $smarty->addConigDir('./config_1'); --- add directory\
// $template_dir = $smarty->getTemplateDir(); ---get directory
// add directory where plugins are stored
// $smarty->addPluginsDir('./plugins_1'); ----add plugins
// get all assigned template vars
// $all_tpl_vars = $smarty->getTemplateVars(); ---get template variables
// print_r($all_tpl_vars);
// $smarty->setCaching(Smarty::CACHING_LIFETIME_CURRENT);
// if(!$smarty->isCached('templates.tpl')) { --returns true if cache is valid for this template
// do database calls, assign vars here}
// load prefilter named 'trim'
// $smarty->loadFilter('pre', 'trim'); --load a filter plugin
// Register a class to use in a template
// class Bar {
// $property = "hello world";
// }
// $smarty = new Smarty();
// $smarty->registerClass("Foo", "Bar");
//$smarty->force_compile = true;
// $smarty->debugging = true;
// $smarty->caching = true;
$smarty->cache_lifetime = 120;
$smarty->assign("Name","Prince");
$smarty->assign("clg","Mangalmay");
$smarty->assign("clg2","institute");
$smarty->assign("code",786);
$smarty->assign("rollno",65);
$smarty->assign("prince","Prince");
$smarty->assign("bar","Prince sinha");
$smarty->assign("foo","Prince sinha");
$smarty->assign('Contacts', array(
'555-222-9876',
'zaphod@slartibartfast.example.com',
array('555-444-3333',
'555-111-1234')
));
$smarty->assign('Movie', 'Two Soviet Ships Collide - One Dies.
Enraged Cow Injures Farmer with Axe.'
);
$smarty->assign('Movie2', 'Movies');
$smarty->assign('start',10);
$smarty->assign('to',5);
$smarty->assign('cust_checkboxes', array(
1000 => 'Joe Schmoe',
1001 => 'Jack Smith',
1002 => 'Jane Johnson',
1003 => 'Charlie Brown')
);
$smarty->assign('customer_id', 1001);
$smarty->assign('myOptions', array(
1800 => 'Joe Schmoe',
9904 => 'Jack Smith',
2003 => 'Charlie Brown')
);
$smarty->assign('mySelect', 9904);
$smarty->assign('cust_radios', array(
1000 => 'Joe Schmoe',
1001 => 'Jack Smith',
1002 => 'Jane Johnson',
1003 => 'Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('templates.tpl');
$smarty->testInstall();
// $output = $smarty->fetch('templates.tpl'); --fetch
// do something with $output here
// echo $output;
?>