-
hakre
php ubuntu php-5.3 php-cli
I have written some code that I run remotely on a server via the php-cli and a particular method within this code (I’m unsure which method at the moment) is causing a segmentation fault.Apart from adding exit and echo calls down through my methods and manually pinpointing the bad bits – is there a way to catch the segmentation fault as it happens and find out what piece of the puzzle is crashing? Standard PHP errors are displayed through the error shutdown handlers, I’m unsure where to start wi
-
Novae
php activerecord iterator visibility php-5.3
I just wanted to implement generic methods on all my classes ( wich represents data from a database ).I wasn’t able to find a reason why this isn’t working, any ideas ? (on php 5.3.1)class ActiveRecord {public function getAttr($attr_name) {foreach( $this as $key => $value) {if( $key == $attr_name )return $value;}throw new Exception( __CLASS__ . ” : Attribut introuvable”);}}class MyClass extends ActiveRecord { public $toto = “Variable public<br>”;protected $tutu = “variable protected<
-
Max
exception-handling php-5.3
I think this is a little weird.I’m running a script, which runs a program. I store the latest output in a variable. If the program or my script for different reasons cause an exception in the script, I catch the exception, append the error log, and rethrow it. A few levels above I catch it again, log the total message, and rethrow it to shut down the script.When PHP command line dies though, it seems to print only the inner exception message in the stack trace, because there is no mention of my
-
BoltClock
php exception namespaces php-5.3
This error is happening when using the Facebook PHP SDK but I actually think it’s a general error.When I run this code, everything works fine and the exception is caught:$facebook = new Facebook(‘appId’=>APP_ID,’secret’=>APP_SECRET); try {$user_profile = $facebook->api(‘/me’,’GET’);echo “Name: ” . $user_profile[‘name’]; } catch(FacebookApiException $e) {$login_url = $facebook->getLoginUrl(); echo ‘Please <a href=”‘ . $login_url . ‘”>login.</a>’; }But when I run this code:
-
j0k
php php-5.3
As of yesterday (perhaps after a recent PHP update?), I’m getting some very strange non-deterministic bugs in php 5.3.3. These appear in our production server in PHP 5.3.2 as well.The errors essentially amount to Fatal error: Uncaught exception ‘ErrorException’ with message ‘Attempt to assign property of non-object’ in various parts of the code base. Generally, the error line is something like: $this->foo = $bar in a __construct() call.$this is not found in the constructor?!I have no idea wha
-
j0k
php php-5.3 xdebug pecl
I’m not too great with xdebug so forgive me if this is a stupid question. But I installed it on a separate machine and it performed some magic for me like formating my var_dump() output and catching any uncaught exceptions. It also fails to format the stack traces, outputting plain text which is extremely hard to read.As I am learning the Lithium PHP Framework I am required to use php5.3, on my other machine I compiled from the source but on this machine I’m using the precompiled packages from d
-
Sammaye
php php-5.3
I have asked a similar question to this one already but I think it was badly worded and confusing so hopefully I can make it a bit clearer.I am programming in a native Linux file system.I have a class of HelpTopic:class HelpTopic extends Help{}And a class of Help:class Help{}Now I go to include HelpTopic:include(‘HelpTopic.php’);And even though I do not instantiate HelpTopic with new HelpTopic() PHP (in a Linux file system) still reads the class signature and tries to load Help with HelpTopic.I
-
Matt
html forms php-5.3 pdflib
It’s my first time up here and PHP is not my strongest point. I’m trying to figure out a way to pass HTML form variables to be used for blocks in PDFLIB 9/PPS using PHP 5. The only information I have found is related to PHP 4 and earlier versions of PDFLIB…and none of it works. I’m currently using a dedicated UNIX server, with shell access, PDFLIB ver9 with PPS and PHP 5.3.25.I can get the pdf doc to create but only if I set the $persons array manually. If I try to put variables in there it co
-
j0k
php php-5.3
I’m no stranger to __get(), and have used it to make some very convenient libraries in the past. However, I’m faced with a new challenge (PHP 5.3, abbreviated and simplified my code for this question):<?php namespace test;class View {function __construct($filename, $varArray) {$this->filename = $filename;$this->varArray = $varArray;}function display() {include($this->filename);}function __get($varName) {if (isset($this->varArray[$varName]))return $this->varArray[$varName];retu
-
user2415992
php sql database mysqli php-5.3
I was wondering how to rewrite/fix the following code.Basically, I have a database named DB and a table in it called poems. I want to get all the data in the poems table that has a certain ID (i.e. who wrote the poem, the tags it has, its content, when it was created, etc.) and securely store it in an array to later be printed out onto a web page.The hosting service I have doesn’t have support for the mysqlnd driver needed for mysqli_getresult(), so I currently get the error “Call to undefined m
-
Alan
php-5.3 html-entities
We’re using PHP version 5.3.2 with FastCGI under Lighttpd 1.4.26:$ /usr/lib/cgi-bin/php5 -v PHP 5.3.2-1ubuntu4.20 with Suhosin-Patch (cgi-fcgi) (built: Jul 15 2013 17:10:44) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologieswith XCache v1.3.0, Copyright (c) 2005-2009, by mOoI’ve got a php script that’s generating a notice to the Lighttpd web server error log:2013-08-30 14:11:46: (mod_fastcgi.c.2711) FastCGI-stderr: PHP Notice: Use of undefined c
-
skaffman
php php-5.3 lambda-functions
The below function takes an array and checks to see if its keys and values match the specified datatypes. I seem to be having some problems with the internal lambda functions that were previously working. I’m running PHP v5.3.6. They last worked under v5.3.4. They are complaining that the non-passed variable is not in scope. If I restate that variable as global then the error goes away, but the variable is empty./*** @param array $arr, array to be tested* @param mixed $keytype* @param mixed $v
-
Daniel Saint James
namespaces php-5.3 composer-php global-namespace
So very strange issue. I only recently starting using auto loading in PHP 5.3+ and of course, this inevitably led to composer. I did a really simple install with composer with only one package, php Image Workshop. In addition to my own auto loader, I fire of the vendor/autoload.phpThen in my code:use PHPImageWorkshop\ImageWorkshop; $imagelayer = ImageWorkshop::initFromPath( $filename );The namespace is valid and I get into the class which immediately throws an error.PHP Fatal error: Call to und
-
j0k
php php-5.3
I’m trying to get some PHP example code to work on PHP version 5.3.4, Apache 2.2.17 on Windows.The example says I need PHP 4.0 and above with CURL and contains:<? $function = $_GET[‘function-if-exist’]; $test = “Test”; ?><? =$test ?>I don’t understand why I’m getting the following errors:My PHP doesn’t understand <? and wants <?PHP instead. My PHP doesn’t like <? =$test ?> and wants something like <?PHP echo $test ?> $function = $_GET[‘function-if-exist’]; causes
-
hakre
php php-5.3
I have a class which is :<?php class FileObject{private $name;private $arr;function __construct($name){$this->name = $name;$arr = array();}public function readFile(){$fileHandler = fopen($this->name, “rb”);while (!feof($fileHandler) ) {$line_of_text = fgets($fileHandler); $parts = explode(‘ ‘, $line_of_text); $count = 0; foreach($parts as $tokens){ $arr[$tokens] = $count; $count++; } }if(checkInArr(“fox”)) echo “yes”; else echo “no”;ksort($arr); print_r($arr); fclose($fileHandler);}func
-
lauthiamkok
php oop multidimensional-array php-5.3 stdclass
I use stdClass to convert an array to an object,function array_to_object($array) {if(!is_array($array)) {return $array;}$object = new stdClass();foreach($array as $key => $value){$key = (string) $key ;$object->$key = is_array($value) ? array_to_object($value) : $value;}return $object; }$type = array(“category” => “admin”,”person” => “unique” );$type = array_to_object($type);var_dump($type->category); // string(5) “admin” and of course an error when I want to get the property w
-
user1678816
php pagination php-5.3
Ok I have the above error on my page, I am using PHP 5.3 for the first time, and have used this code before but never had this notice, so I was hoping for some guidance. I have looked at some questions but when I try to apply the solution to my bit of code it doesn’t seem to work. This code is a PHP pagination script from paper mashup and so if I can find the answer it may help anybody else who is also using this code and experiences the same problem.the piece of code which is generating the
-
Chris
php cakephp php-5.3
I manage a CakePHP 1.1 CMS website, and our hosts just upgraded PHP to 5.3, causing a number of errors, such as:Notice: Undefined variable: banner_image in /home2/intiwara/cake/app/views/layouts/public_site.thtml on line 49 Notice: Undefined variable: news_menu in /home2/intiwara/cake/app/views/articles/volunteer_animal_refuge.thtml on line 73I can hide the errors by altering cake/cake/libs/configure.php line 133 to be:error_reporting(E_ERROR);However the variables and models are still not found
-
Jason
php lambda closures php-5.3 lambda-functions
I have a list of functions a(), b(), c() I have a main() function. Depending on case, I need to pass a different function to main() to use. In javascript it would be:var a = function(){} var b = function(){} var c = function(){}var func = (some logic) a, b or c;main(func);How do I do that in php5.3? I am trying to avoid using $func_name = “a”; main($func_name){$func_name(); }Or may be it is the best way, and I should not use closures of any type?
-
Charles
php php-5.3 unicode-normalization
I am trying to use the normalizer_normalize() function introduced in PHP 5.3 (says the doc), however I can’t use it:$ php -r ‘echo normalizer_normalize(“tést”);’ PHP Fatal error: Call to undefined function normalizer_normalize() in Command line code on line 1I’ve checked my PHP version but it’s 5.3:$ php –version PHP 5.3.6 (cli) (built: Sep 12 2011 18:02:42)I don’t understand why PHP can’t find it?
-
ThiefMaster
php php-5.3
With this test page:$page = (int) $_GET[‘page’] ?: ‘1’; echo $page;I don’t understand the output I’m getting when page is undefined:Request Result ?page=2 2 ?page=3 3 ?page= 1 ? error: Undefined index pageWhy the error message? It’s php 5.3, why doesn’t it echo “1”?
-
Autolycus
php php-5.3
Possible Duplicate:Why do I need the isset() function in php? whats the difference if I say if($value){}vs if (isset($value)){}I had been asked to change if($value) to isset($value)thanks
-
EOB
properties null php-5.3
Hello I am making this call:$parts = $structure->parts;Now $structure only has parts under special circumstances, so the call returns me null. Thats fine with me, I have a if($parts) {…} later in my code. Unfortunately after the code finished running, I get this message:Notice: Undefined property: stdClass::$parts in …How can I suppress this message?Thanks!
-
Spechal
php acl php-5.3 anonymous-function
I am trying to hack an ACL into a Template without making the Template aware of the ACL object in the class definition. The following code generates an undefined method Template::isAllowed Why is this? TIA!class ACL {protected $allowed = array(‘anything’);public function isAllowed($what){if(in_array($what, $this->allowed))return true;return false;}}class Template extends stdClass { }$Template = new Template;$ACL = new ACL;$Template->isAllowed = function($what) use($ACL) { return $ACL->isAllowe
-
bwoebi
php php-5.3
Trying to help someone with their php based site, I cannot run it locally as I get errors for ‘Undefined variable: dbhost’ etc. when trying to use any page that connects to mysql.dbConfig.php:<?$dbhost=”HOST”; // Host name $dbusername=”USER”; // Mysql username $dbuserpass=”PASS”; // Mysql password $dbname=”NAME”; // Database name ?>Excerpt from including php file (e.g. login.php):include_once (“../include/dbConfig.php”); $db_handle = mysql_connect($dbhost, $dbusername, $dbuserpass) or d
-
j0k
php variables undefined php-5.3
I was toying around with some PHP today, doing what I normally do when I try a language I either don’t know or am rusty in: write a small crappy card game.The first task was to roll out a sorted deck with all the available cards. Here was my (failed) attempt:<?php$sorted_deck = array_map(function($suit) {$card = function($rank) {return array(‘suit’ => $suit, ‘rank’ => $rank);};returnarray_map($card, range(2, 10))+ array_map($card, array(‘jack’, ‘queen’, ‘king’, ‘ace’));}, array(‘clubs’,
-
j0k
php php-5.3
Is it possible to handle this type of errors? Something like spl_autoload_register, but for functions.Basically, what I am trying to do:I have the class:class Foo {public function bar() {echo 1;} }So, when I call a nonexistent function Foo() like this:Foo()->bar();The possible handler should create a function Foo(), which looks like that:function Foo() {return new Foo(); }
-
Caffeinated Aviator
zend-framework hudson phpunit php-5.3 phing
Every build has failed as of Tuesday. I’m not exactly sure what happened. The Phing targets (clean/prepare) are being executed properly. Additionally, the unit tests are passing with flying colors, with only a warning for duplicate code (not a reason for a fail). I tried removing the phpDoc target to see if that was causing the error, but the build still failed.Started by user chris Updatingfile://localhost/projects/svn/ips-com/trunkAt revision 234 no change forfile://localhost/projects/svn/
-
Matthieu Napoli
php reflection php-5.3
I am using Reflection against the following class:class Constant {const CONSTANT = 3;public $test1 = ‘CONSTANT’;public $test2 = CONSTANT; }When using ReflectionClass::getDefaultProperties(); I get the following notice:PHP Notice: Use of undefined constant CONSTANT – assumed ‘CONSTANT’on this line of code:$defaultValues = $reflectionClass->getDefaultProperties();First, I wonder why I get the notice here (I mean, I can’t anticipate/avoid the notice even though the code is 100% correct)?And seco