I am using php 5.2.6 in AppServ on a Windows machine and PHPExcel does not seem to work and produces no errors. I have error_reporting set to E_ALL.
On my Linux machine where I am using php 5.6 and using vagrant/homestead the same code works just fine.
Here is my code:
http://pastebin.com/6dJC8gaP
I added some echos to see where exactly it dies, and it seems to die on line 9. I had thought maybe it was an issue with php 5.2 and :: referencing, so I tried using the call_user_func, which also works on my php 5.6 but does not work on my php 5.2
http://php.net/manual/en/function.call-user-func.php
<?php
namespace Foobar;
class Foo {
static public function test() {
print "Hello world!\n";
}
}
call_user_func(__NAMESPACE__ .'\Foo::test'); // As of PHP 5.3.0
call_user_func(array(__NAMESPACE__ .'\Foo', 'test')); // As of PHP 5.3.0
?>
Per page:
Quote:
In PHP v5.2, you /can/ use call_user_func(array($this, 'parent::SOME_FUNCTION')).
If you don't have custom __autoload() function, you are good to go.
If you do have custom __autoload(), you need to make it `parent' aware. Something like:
Rationale: PHP 5.2 surprisingly tries to autoload a class named 'parent'. However, if you don't do anything in __autoload() for the 'parent' class, it'll work just fine.
In PHPExcel/Settings.php there are two references to libxml_disable_entity_loader function.
That function is not available until php 5.2.11, and the # in front of it was causing a silent error.
I did as they suggested and wrapped that function in function_exist checks. Everything works fine now.
Reference: https://github.com/PHPOffice/PHPExcel/issues/339
Related
I am trying to get my localhost db listed in phpPgAdmin, but it says No object found phppgadmin GUI
I have already configured conf/config.inc
$conf['servers'][0]['desc'] = 'PostgreSQL'
$conf['servers'][0]['host'] = 'localhost';
$conf['servers'][0]['port'] = 5432;
$conf['owned_only'] = false;
Any help please, I have tried with Postgresql versions 9.2,9.5,10.3(not supported by phppgadmin?)
EXPLANATION OF THE PROBLEM
I see the problem! This error message is a bug in the phpPgAdmin code, which apparently has older code that was written before PHP 7.x was released.
The error in phpPgAdmin will appear if you've recently downloaded a technology stack with all of the latest versions of PHP, PostGreSQL and phpPgAdmin. For example... today's (Feb. 2019) latest versions are:
PHP 7.3.1
PostGreSQL version 11
phpPgAdmin 5.6 (Nov. 12, 2018) <= This doesn't work with PHP 7.x, but we want it to work with it and we can make it work with it!
PHP.net explains the problem in their Constructors and Destructors page:
Warning Old style constructors are DEPRECATED in PHP 7.0, and will be
removed in a future version. You should always use __construct() in
new code.
Their example is in this section on that page:
Example #2 Constructors in namespaced classes
<?php
namespace Foo;
class Bar {
public function Bar() { <- This is an older style of creating a constructor.
For PHP 7.x, it should be changed to "__construct" instead of "Bar".
// treated as constructor in PHP 5.3.0-5.3.2
// treated as regular method as of PHP 5.3.3
}
}
?>
Now that we know what the problem is, here is how to solve it.
SOLUTION
Look in your /phpPgAdmin/ folder on your web server. You should find the following files in the /classes/ sub-folder:
ArrayRecordSet.php <- Replace function ArrayRecordSet with function __construct
class.select.php <- Replace function XHtmlSimpleElement with function __construct
Gui.php <- Replace function GUI with function __construct
Misc.php <- Replace function Misc() with function __construct
Plugin.php <- Already has function __construct
PluginManager.php <- Already has function __construct
Edit those files & change any of the constructor names - which appear as duplicate class names - to __construct.
When you save those files & reload phpPgAdmin in your browser, then you will see that the "No objects found" message will have disappeared. It will then display a server name.
VoilĂ ! The latest version of phpPgAdmin 5.6 works with the latest version of PHP 7.3.1 & the latest version of PostGreSQL 11!
If you want to check the XML contents of that left tree, simply append this to your website as this is the rest of the URL, which it's using: /phppgadmin/servers.php?action=tree. That will help make debugging the phpPgAdmin code easier to do.
You can also remove the action=tree querystring parameter. Or search for it inside of the phpMyAdmin code.
BUG REPORT
I'll see about submitting a phpPgAdmin bug report to with the link to this page. Hopefully, someone will fix this error in the phpPgAdmin code base.
Have fun using the latest version of phpPgAdmin, PHP & PostGreSQL!
I am using RAP API for PHP on Netbeans. There is a function named NAMESPACE located at rdf_api/api/OWLVocabulary.php and rdf_api/api/OWLVocabulary.php
and the NAMESPACE is creating a Syntax error.
function NAMESPACE()
{
return RDF_SCHEMA_URI;
}
Namespace is a reserved keyword since PHP 5.3.
You will probably find that the library you're using only works in earlier versions of PHP.
Indeed, it will have worked up to PHP 5.2:
https://3v4l.org/EUqOu
I am using PHPUnit to test my project running in PHP 7.0.2, but it seems to have issues with the group use statement. For example, this is an example file using a group use statement:
test.php
<?php
namespace MyFramework;
use \OtherFramework\{
AwesomeClass,
OtherAwesomeClass
};
// do ALL the things
When I run
php test.php
it works fine as expected. Now I was using PHPUnit 4.8.21, but when I tried
phpunit test.php
I got the error
Parse error: parse error, expecting `"identifier (T_STRING)"' in test.php on line 4
Mind you, I am using other PHP 7 features such as the null coalesce operator (??) just fine in other tests, so I know that PHPUnit is running PHP 7. Next I tried upgrading to the preferred stable version (5.1.4) and got this response:
This version of PHPUnit requires PHP 5.6; using the latest version of PHP is highly recommended.
And even my old tests without a group use statement won't run.
How can I run PHPUnit with PHP 7 and get the group use statements to work?
I am trying to change the path of a file (saved in /foo/bar directory) to the root
forexample
www.example.com/foo/bar/user.php
to
www.example.com/user.php
using chroot() function
<?php
chroot("/foo/bar/user.php");
$n=getcwd();
echo $n;
it's not working, I am getting the following php error :
call to undefined function chroot()
I am using php 5.3*, But I have also tested it on 5.4+ , still the same error. I am not sure if it is because of the the versions or something else,
Please help!
Note the following from the docs page:
This function is only available to GNU and BSD systems, and only when
using the CLI, CGI or Embed SAPI. Also, this function requires root
privileges.
Are you trying to use it on a Windows platform? If so this will not work.
I'm calling http_get_request_headers() in a PHP file on a server running PHP 5. However, I'm getting Fatal error: Call to undefined function http_get_request_headers(). Does anyone know what the problem might be? Does this function not come with plain PHP?
No it does not. You need a PECL module for that function to work. But you can use the contents of the $_SERVER variable as stated in this comment on the php site. Alternatively you can use the apache function if this is your web server.
If you're using version >= 2 of pecl_http you'll need to use the namespace syntax for calling the functions. Check out the version 2 documentation here and example here
Basically \http\Env::getRequestHeader()
That function is part of the PECL extension.
Follow the instructions on this page to install it: http://ar.php.net/manual/en/http.install.php
Have you read the Installation and Configuration guide for the HTTP classes/functions?