Call to undefined session_set_cookie_params() - php

I want use php function "session_set_cookie_params()", but it isn't work.
Here is source code.
$ cat test.php
<?php
error_reporting(E_ALL & ~E_NOTICE);
session_set_cookie_params(0, '/dir/');
?>
$ php -v
PHP 5.4.16 (cli) (built: Jul 5 2013 00:19:53)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
$ php test.php
Fatal error: Call to undefined function session_set_cookie_params() in / (...) /dir/test.php on line 3
(On web browser, same output.)
I think php config file (/usr/local/etc/php.conf) have a problem, but it is seem to don't have problem. (It is default.)
Could you tell me answer this question ?

Related

"Which php" showing incorrect path in mac os

I am doing "which php" in my mac book and its giving me the output as below :-
/usr/bin/php
While in path variable its showing me :-
~ manishk$ echo $PATH
/Applications/XAMPP/xamppfiles/bin/php-5.6.24:/usr/local/rvm/gems/ruby-2.1.2/bin:
Which php should point to php-5.6.24 .
Even php --version is giving me
PHP 5.4.30 (cli) (built: Jul 29 2014 23:43:29)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
I don't know where to set it to correct it .
The $PATH variable is ment as a list of directories, where your command binaries can be found. So, you have to add the directory where the php binary is located.
For XAMPP this means, you'll have to add the following path to your $PATH variable:
/Applications/XAMPP/bin
As this is a symlink to xamppfiles/bin, you can also use this one:
/Applications/XAMPP/xamppfiles/bin

MySQLi reported missing, only in console

I'm using XAMPP and PHP CLI to test my PHP script locally. The problematic line (the line 98) in db.php is:
$this->mysqli = new mysqli($host, $user, $pass, $dbname, $port);
And the error is:
No such file or directory in /path/to/my/file/db.php on line 98
This problem only appears when I execute a PHP file that requires db.php in Terminal. It works fine when I run it in browser. How come?
The CLI command I use is:
php test.php
Well, that's a very simple command. Is there anything I missed?
Note: I'm using Mac OS X 10.10.1
PHP version:
PHP 5.5.14 (cli) (built: Sep 9 2014 19:09:25)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

Fatal error: Class 'COM' not found PHP. Win7 - Apache - PHP

$myapp = new COM("word.application");
// returns a fatal error: "Class 'COM' not found in c:/www/comConnector.php"
shell_exec("whoami");
//returns "NT authority/system"
My system setup
Win7 Pro
Apache Server version: Apache/2.2.23 (Win32)
PHP
PHP 5.3.16 (cli) (built: Aug 15 2012 20:06:57)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
Add COM support in php.ini:
[COM_DOT_NET]
extension=php_com_dotnet.dll
Since you are using PHP 5.3.16, make sure that you are pointing to the global namespace:
$myapp = new \COM("word.application");
Even though your PHP file might be in global namespace already, but it's a good practice.

Is there a PHP setting that sets whether you can index the result of a function?

I have two servers. They are both running php 5.3.3. This code works on one server and returns a syntax error on the other. Is there a php ini setting that affects this behaviour? I can't find anything related in the PHP documentation, but I may be looking in the wrong place.
Server 1
> php -v
PHP 5.3.3 (cli) (built: Sep 23 2010 14:15:16)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans
php > echo explode(" ", " foo ")[1];
foo
Server 2
> php -v
PHP 5.3.3 (cli) (built: Jan 31 2011 15:57:29)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
php > echo explode(" ", " foo ")[1];
Parse error: syntax error, unexpected '[', expecting ',' or ';' in php shell code on line 1
Another idea: PHP on both servers is custom-compiled, so it could also be a different compile flag.
No.
PHP doesn't support this syntax. It's on the trunk, but not yet released (as of PHP 5.3.3).
I have no idea how it's working on your first server, but perhaps this "Xdebug" is making a difference?
Aha! I figured it out.
We installed Facebook's XHP to profile our development server. This syntax (which is quite elegant) was added in in the PHP module. Here's a diff of the php.ini file between server 1 and 2:
> ; XHP https://github.com/facebook/xhp/wiki/Building-XHP
> extension=xhp.so
> ; adds support for the [] operator on the return value of a function
> xhp.idx_expr = 1
> ; Tracking errors in XHP applications is very difficult without annotations.
> xhp.include_debug = 1
I like this syntax, so I'll probably install XHP on the other server. Thanks for the help Michas for suggesting I diff the ini files.

strange behaviour of php session

im using php a server, that uses ubuntu 8.04 :
PHP 5.2.4-2ubuntu5.12 with Suhosin-Patch 0.9.6.2 (cli) (built: Sep 20 2010 13:33:05)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
i found a strange behaviour:
<?php
session_name('session');
session_start();
$_SESSION['username']='realName';
$username='otherName';
?>
this leads to, that php saves in the session variable 'otherName' (instead of 'realName'). why is php saving the $username into the session variables? How can i disable this?
thanks in advance for any help... :)
It looks like you have register_globals = on in your php.ini. This option has been deprecated as of PHP 5.3 and you should turn it off. More information can be found here: http://www.php.net/manual/en/security.globals.php

Categories