Jump to content


Shoel

Member Since 22 Apr 2010
Offline Last Active Yesterday, 05:35 PM
-----

Posts I've Made

In Topic: Issue with a field

03 February 2012 - 10:09 AM

Hi there,

I would be glad to help, but first.. please post properly formated code; the above is not readable at all, there's way too many line breaks. Also, use the "< >" button in the editor to enclose the code in the appropriate formating tags.

Quote

<?php

global

$wpdb

,

$paypali_membership_vars

,

$posted

;

?>


Should for an example read...


Quote

<?php

global $wpdb,$paypali_membership_vars, $posted;

?>


If you are not familiar with common coding standards for PHP, this guide (click me) will give you a decent intro. :)

- S.

In Topic: what we can do for security of code in php ?

03 February 2012 - 09:48 AM

I've replied to your previous 8 posts without you participating actively in the discussions you've tried to set off there (and where you've often repeated the same question over and over again) - hence I am starting to think that you only post here in a hope to expose the promotion text and website you have in your profile. I will therefore not bother with a reply, unless you are more specific and show a genuine interest in learning.

In Topic: Problem updating Cookie on live host

03 January 2012 - 03:06 PM

Hi Kingdom,

Welcome to PHPTalk.com! :)

The first thing that strikes me is the $site variable. In a class this needs to be declared using the var keyword, like this:

<?php

class TestClass {

  var $site = '.ciadacapa.com.br';

  (...)
}
?>
(Alternatively, if working with PHP 5.x, the private or public keywords should be used instead.)

Otherwise PHP will throw a Parse error: syntax error. If you are working on a webserver which has error reporting disabled, you would not see this.

In Topic: [5.4] What's the point with "insteadof"?

02 January 2012 - 10:45 AM

Hi Rulatir,

Welcome to PHPTalk.com, and a Happy New Year!

I can't say I've had the chance to get my hands dirty with all the new features of PHP 5.4.0 yet, so I do not have much experience with Traits. From what I gather, however, the point of Traits is to function similar to interfaces in other languages - and allow easier/cleaner code reuse...without complicated multiple inheritance. The "insteadof" keyword allows us to deal with conflicts if multiple Traits have methods of the same name, for an example in cases where we'd like to use several Traits from 3rd party sources without modifying the originals.

If we do not have a conflict... we can merely use the syntax

<?php
use A, B;
?>

To use the two Traits A and B.

If both A and B have a method called exampleMethod, we need to explicitly resolve the conflict:

<?php

use A, B {
  B::exampleMethod insteadof A;
}
?>


(Here exampleMethod of Trait B will be used instead of that of A.)

I'm not sure what the exact syntax is in cases where we have 3 or more Traits with the same method name (and I do not have a PHP 5.4.x server to test on at this moment)... but I assume that it'll be something like this:

<?php

use A, B, C {
  B::exampleMethod insteadof A and C;
}
?>
(This is a mere guess... and may not be accurate.)

If I understand you correctly... you are wondering why we cannot just tell it to use B's method using something along the lines of...

<?php

use A, B, C;
use B::exampleMethod;
?>

...to tell PHP that we'd like to use B's exampleMethod regardless. Avoiding having to explicitly declare each and every conflicting Trait with the "insteadof" keyword.

To me... it makes more sense to do it the way the current implementation works (assuming that my assumption of having to explicitly list all the conflicting traits with the insteadof statement is correct). Why? Well... for the sake of keeping things predictable and make sure the developer is aware of what he is doing. Otherwise we can get weird behavior that can be time consuming to track down.

- S.

In Topic: PHP development with Webuzo

21 December 2011 - 12:50 PM

Hey phpnew,

Apologies for the late response. We've had some issues with the forum lately, and I seem to have missed your entry.

If you still require assistance with this - please do let us know!

- S.