altergothen
-
Posts
5 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Downloads
Gallery
Store
Posts posted by altergothen
-
-
Hi there
Please can someone point me in the right direction, where in the documentation can I read up on the following notation?...
I am trying to figure out what the purpose of the braces around the variable are? $this->{$spec}
if (is_string($spec)) {
$subForm = $this->{$spec};
}
-
IS there an easier way to get a single result from a PDO query than having to run a foreach when I already know that there should only be a single record or value being returned?
I tried using $myresult = $dbh->exec($sql); ...but only returns a 1
$dbh = new PDO("$Driver1:host=$Server1;dbname=$db1", $User1, $Password1);
try {
$sql = "SELECT FileVersion FROM FileVersion WHERE GroupID = $GroupID ORDER BY FileVersion Desc";
foreach ($dbh->query($sql) as $myrow)
{
$FileVersion = $myrow['FileVersion'];
}
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
-
Variable Variables???
I am used to concatenating variables like this when doing procedural PHP like this ....
$i=5;
${"varnumber_$i"} = 'This variable should be called varnumber_5';
How do I make a variable variable in a PHP5 class ?
How do I achieve the following without resorting to Case Statements?
.... here is my event handler in my class :
public function handleAction( $i ){
$this->handleEvent_$i
}
public function handleEvent_1 () {
echo "Handling Event1";
}
public function handleEvent_2 () {
echo "Handling Event1";
}
public function handleEvent_3 () {
echo "Handling Event1";
}
-
Hi there
How do I concatenate variable variables from instance vars?
Thanks...much appreciated
<?php
class myClass {
var $testme1 = "one";
var $testme2 = "two";
var $testme3 = "Three";
function __construct(){
echo "
Concat test
";}
}
$myInstance = new myClass();
for ( $i=1; $i <= 4; $i++) {
$testme = ${"testme"."$i"};
$myVar = ${"testme"."$i"};
echo $this->$myVar; //???????????????????????????????????????????
}
Notation in the documentation?
in PHP
Posted · Edited by altergothen
Ahh! variable variables!!!
Thank you very much lwsimon
PHP.Net is great if you just know what you are looking for