Tag Archives: variables

Annoying PHP error: “Strict Standards: Only variables should be passed by reference in”

Questions: I have this small script made and I cant get this error: Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\includes\class.IncludeFile.php on line 34″ off! Here is the page: namespace CustoMS; if (!defined(‘BASE’)) { exit; } class IncludeFile { private $file; private $rule; function __Construct($file) { $this->file = $file; $ext = $this->Extention();… Read More »

PHP sending variables to file_get_contents()

Questions: I want to be able to send a few variables to a file through file_get_contents(). This is firstfile.php: <?php $myvar = ‘This is a variable’; // need to send $myvar into secondfile.php $mystr = file_get_contents(‘secondfile.php’); ?> This is secondfile.php: The value of myvar is: <?php echo $myvar; ?> I want the variable $mystr to… Read More »

PHP variables reference and memory usage

Questions: According to php manual: <?php $a =& $b; ?> // Note: // $a and $b are completely equal here. $a is not pointing to $b or vice versa. // $a and $b are pointing to the same place. I assume that: <?php $x = “something”; $y = $x; $z = $x; should consume more… Read More »

Can you unset() many variables at once in PHP?

Questions: I have a pretty high traffic social network site, I would like to get into the habit of unsetting large array and mysql object and even some string variables. So is it possible to unset more then 1 item in PHP example: <?PHP unset($var1); // could be like unset($var1,$var2,$var3); ?> Answers:

Error: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables

Questions: I am not sure what is wrong, everything seems to be fine. Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn’t match number of bind variables on line 88 <?php error_reporting(E_ALL); ini_set(‘display_errors’, 1); include_once ‘db_connect.php’; include_once ‘ex-config.php’; $error_msg = “”; if (isset($_POST[‘username’], $_POST[’email’], $_POST[‘p’])) { // Sanitize and validate the data passed in… Read More »

.htaccess for friendly URL with multiple variables

Questions: I am working on making my site more SEO friendly I am currently using RewriteEngine On RewriteRule (.*)$ index.php?page=$1 To turn site.co.uk/index.php?page=page_name into site.co.uk/page_name I want to also use this for sub pages too. I have tried this: RewriteEngine On RewriteRule (.*)/(.*)$ index.php?page=$1&subpage=$2 but its not working, it runs site.co.uk/page_name/sub_page but when you go… Read More »

Which is better on performance: double quoted strings with variables or single quoted strings with concatenations?

Questions: I know that using single quotes around a string in PHP is faster than using the double quotes because PHP doesn’t need to check for variable presence in the single quoted string. My question is which will perform better: A) A double quoted string with variables present: echo “foo bar $baz”; or B) Single… Read More »