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
Related
this my /usr/local/ folder
this my php version showing`
PHP -v
PHP 5.5.38 (cli) (built: Mar 30 2017 12:11:07)
Copyright (c) 1997-2015 The PHP Group Zend Engine v2.5.0,
Copyright (c) 1998-2015 Zend Technologies`
this is my PATH
echo $PATH
/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
What i want to do is switch to my php72 folder so when i type php -v to show me php 7.2
I have searched a lot and tryed many solutions but it is not working.
any help would be appreciated
Go in the Finder and press ⌘⌥P to turn on the display of the path at the bottom of the screen - no idea why Apple leaves this turned off (rant over).
Now navigate to /usr/local/php5-7.2ORC.... and navigate around in there till you find the executable called php. Note the path at the bottom of the screen when you have that file selected. Remove the word php from the right end of that path, now set your PATH like this:
export PATH=<WHATEVER-YOU_GOT_ABOVE>:$PATH
In essence, you will end up doing something like:
export PATH=/usr/local/php5-7.20ORC.../bin:$PATH
I need to use a php script without "php" command.
For example:
$ ./test.php
Permissions are sets to 755.
This is the script
#!/usr/bin/php -q
<?php
echo "hello world";
?>
/usr/bin/php -v (so path exists)
returns
PHP 7.0.15-1+deb.sury.org~xenial+1 (cli) (built: Jan 20 2017 08:53:13) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.15-1+deb.sury.org~xenial+1, Copyright (c) 1999-2017, by Zend Technologies
This is the error I'll get everytime:
Exception: Zend Extension ./test.php does not exist
Also calling script with fullpath I'll get same error.
Calling this it works properly
$ php ./test.php
Any idea?
NOTE: The author found the solution and put it up in the comments but never posted an actual answer, so this answer is just clarifying what the author already said above so as to make the answer more obvious.
I was also getting the Exception: Zend Extension does not exist when I was trying to pipe an email via cpanel forwarder into a php script.
I opened the file in my editor (Komodo Edit on Windows) and went to EDIT > CURRENT FILE PREFERENCES and noticed that LINE ENCODINGS was set to DOS/Windows (\r\n)
I changed the LINE ENCODING to UNIX (\n) and saved it and re-uploded it and the error went away and all is good now.
Obviously the steps will vary depending on what editor you use, but the solution is to make sure your Line Encodings are UNIX and not DOS/Windows.
Just run dos2unix on the file
# ./database.php
Exception: Zend Extension ./database.php does not exist
# apt install dos2unix
# dos2unix database.php
dos2unix: converting file database.php to Unix format...
# ./database.php
Yeah!!! It work's!!!!
i have a function wich makes a check if a folder is writable. but when i try to use the php touch variable in it like this
public function isFileServerMounted()
{
$config = $this->getServiceLocator()->get('config');
$storageDir = $config['xxx']['xxx']['xxx'];
$mountCheckFile = $config['xxx']['xxx']['xxxx'];
// we are using a simple file check as indication if we are mounted
return touch($storageDir . DIRECTORY_SEPARATOR . $mountCheckFile);
}
The function always returns true, regardles if the file i am checking is there or not. i checked the paths and they are correct and i can acess the file via nano over schiell.
The touch comand always returns true, regardles if i delete or make the mount check file.
Anyone has any idea why?
I am using:
PHP 5.3.3-7+squeeze19 with Suhosin-Patch (cli) (built: Feb 17 2014 10:10:23)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
OS:
Distributor ID: Debian
Description: Debian GNU/Linux 6.0.3 (squeeze)
Release: 6.0.3
Codename: squeeze
touch() is to sets access and modification time of file.
If the file does not exist, it will be created.
Maybe you can use file_exists like this:
$filename = $storageDir . DIRECTORY_SEPARATOR . $mountCheckFile;
if (!file_exists($filename))
return false;
return touch($filename);
$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.
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.