Basic variable-parameter issue
Moderator: General Moderators
- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
IIRC, php manual doesn't mention this anywhere, kind of "implied knowledge" I guess.fwc wrote:While I'm at it can someone please explain the syntaxOk, thanksCode: Select all
->
-> is an "of" operator, "foobar->quux" means "quux of foobar". It's used to access object's properties and methods.
And no, it has nothing to do with references and dereferencing.
Code: Select all
<?php
// The linked you clicked on what something like 'mysite.com?page=about'
include ('db_config.php');
$page = strtolower($_GET['page']);
include ('header.php');
switch($page){
default:
echo "<p>YEA</p>";
echo "<a href=/eclipse_projects/?page=about>About</a><br>";
break;
case 'about':
echo "<p>We're the smurf!</p>";
echo "<a href=/eclipse_projects/?page=home>Home</a><br>";
break;
case 'contact':
echo "<p>Contact Page!</p>";
echo "<a href=/eclipse_projects/?page=home>Home</a><br>";
break;
}
include ('footer.php');
?>And you were getting a blank page, because none of your if statements where validated TRUE.
thanks very much to the three posts above me, I understand better what the -> means
As for my browsing that is a good option but I found one that worked
EDIT: I just looked at Zoxive's a little closer and it is actually very good, thanks a bunch
As for my browsing that is a good option but I found one that worked
EDIT: I just looked at Zoxive's a little closer and it is actually very good, thanks a bunch
Code: Select all
<?php
include ('db_config.php');
//Get page info
$page = $_GET['page'];
if (!$page)
{
include ('header.php');
include ('body1.php');
echo "<a href=/eclipse_projects/?page=about>About</a><br>";
include ('footer.php');
}
//About Page
else if ($page == 'about')
{
include ('header.php');
echo "<p>We're the <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>!</p>";
echo "<a href=/eclipse_projects/?page=home>Home</a>";
include ('footer.php');
}
//Contact
else if ($page == 'contact')
{
echo "<p>Contact Page!</p>";
echo "<a href=/eclipse_projects/?page=home>Home</a><br>";
}
?>Ok, well I'm looking over Smarty and the potential uses of templates but I can't figure out what these "->" symbols are doing. Are they storing information into $tpl?stereofrog wrote:IIRC, php manual doesn't mention this anywhere, kind of "implied knowledge" I guess.fwc wrote:While I'm at it can someone please explain the syntaxOk, thanksCode: Select all
->
-> is an "of" operator, "foobar->quux" means "quux of foobar". It's used to access object's properties and methods.
And no, it has nothing to do with references and dereferencing.
EDIT: Ok, wait nevermind, they must be getting information from $tpl?
Code: Select all
<?php
require_once('Smarty.class.php');
$self = $DOCUMENT_ROOT . $PHP_SELF;
$tpl = new Smarty;
$tpl->template_dir = dirname($self);
$tpl->compile_dir = $tpl->template_dir . '/.smarty/templates_c';
$tpl->config_dir = $tpl->template_dir . '/.smarty/configs';
$tpl->cache_dir = $tpl->template_dir . '/.smarty/cache';
$tplname = basename($self);
$cacheid = '';Code: Select all
<?php
class Dog{
$name = 'None';
function name(){
echo $this->name;
}
}
$var = new Dog(); // $var is now an Instance of the Class Dog
$var->name(); // Calls the function name in the class Dog
// Echos 'None';
$var2 = new Dog();
$var2->name = 'Spot';
$var2->name();
// Echos Spot
?>thankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyouZoxive wrote:PHP ManualCode: Select all
<?php class Dog{ $name = 'None'; function name(){ echo $this->name; } } $var = new Dog(); // $var is now an Instance of the Class Dog $var->name(); // Calls the function name in the class Dog // Echos 'None'; $var2 = new Dog(); $var2->name = 'Spot'; $var2->name(); // Echos Spot ?>