PHP serialize - PHP::Serialization
Original post provide by php-BloggerIch muss ein PHP object über ’serialize’ serialisieren, an Perl weiterreichen und dort über das Modul PHP::Serialization auspacken. Ich habe Stunden damit zugebracht herauszufinden, warum ich auf meine Objektvariablen nicht zugreifen kann.
class test {
public $public_key = ‘public_val’;
private $private_key = ‘private_val’;
}
"Eigentlich" ist es logisch, dass PHP "auf irgendeine Art und Weise"” im serialisierten String kenntlich machen muss, welche Bestandteile des Objekts private und welche public sind, da ansonsten PHP selbst das Objekt nicht mehr korrekt deserialisieren könnte. Solchen Fragen muss man sich aber erst stellen, wenn man ein seralisiertes Objekt mit etwas anderem als PHP weiterverarbeiten möchte … . Der Data::Dumper von Perl jedenfalls gibt für das deserialisierte Objekt folgendes zurück:
$VAR1 = bless( {
’public_key’ => ‘public_val’,
’testprivate_key’ => ‘private_val’
}, ‘PHP::Serialization::Object::test’ );
Die Ausgabe von …
print Dumper($obj->{'testprivate_key'});
… liefert jedoch ein “undef” - was ist da los? Ganz einfach: PHP fügt nicht nur den Namen der Klasse in den Namen der Objektvariablen beim Serialisieren des Objektes ein, sondern zusätlich vor und hinter dem Namen der Klasse je ein null-Byte:
0000000: 4f3a 343a 2274 6573 7422 3a32 3a7b 733a O:4:"test":2:{s:
0000010: 3130 3a22 7075 626c 6963 5f6b 6579 223b 10:”public_key”;
0000020: 733a 3130 3a22 7075 626c 6963 5f76 616c s:10:”public_val
0000030: 223b 733a 3137 3a22 0074 6573 7400 7072 “;s:17:”.test.pr
0000040: 6976 6174 655f 6b65 7922 3b73 3a31 313a ivate_key”;s:11:
0000050: 2270 7269 7661 7465 5f76 616c 223b 7d ”private_val”;}
Ein Dank an dieser Stelle geht an Plu, der mir beim Debuggen geholfen hat und nicht müde wird all meine Perl-Fragen zu beantworten.
Previous Articles:IMAP Mit Google Mail
Der IMAP Zugang muss zunächst in den Einstellungen aktiviert werden, diese sind derzeit allerdings nur in der englischen Version von Google Mail verfügbar (einfach die Spracheinstellung in Google Mail auf 'englisch' ändern). Habe das ganze mal mit Apple Mail ausprobiert - es funktioniert wunderbar.
The Internet Is The New Unix
Mashups are of course a valuable byproduct of open data, but I can't think of many mashups that I use daily. If someone wants to combine Dopplr with upcoming shows, so that I don't miss a chance to see my favorite musical artists, that might change.
Open Source Developers' Conference 2008 - Sydney - Call For Papers
It is a great opportunity to meet, share, and learn with like-minded individuals. This year, the conference will be held in Sydney, Australia during the first week of December. If you are an Open Source maintainer, developer or user, the organising committee would encourage you to submit a talk proposal on open source tools, solutions, languages or technologies you are working with.
How To Create A Press Kit That Attracts Positive Media Attention
You can always go back later and add this list as you grow. Step 5. Market Focus. Describe your target audience including all applicable demographics and psychograpics. Demographics cover characteristics such as age group, gender, social class, average yearly income, religion, location, and any other relevant factors.
Web Site Gray Text Trend
There’s a reason for that — it’s readable. Most of us scan rather than read Web pages. Gray text is a barrier for scanning because it requires working harder to make out the text as it doesn’t have a strong contrast to the background.
More Articles:
PHP Comes To DC
(I suspect Ed is more well known as the developer of Spaz.) Not to be outdone, we are going to have a booth (our first booth!), Paul is giving a talk on framework and application benchmarking, Nate is giving a tutorial on CakePHP, and I'm giving the opening keynote.
Microsoft Web Development Summit 2007
I’ll be taking time to condense my thoughts and reactions into a single blog post later this week after I’ve returned home and rested, but for now, you can follow along as I take notes on my personal “notes” wiki.
International PHP Conference 2007 Spring Edition : Call For Papers
There's a pre-conference day on 21st of May with full day Power Workshops and a Main Conference from 22nd to 23rd of May with 1 hour sessions. Please submit your session proposals at http://phpconference.com/input. They will be voted by the Chair board consisting of Björn Schotte (Head of Chair), Christopher Kunz and Sebastian Meyen.
Remember, Remember
(If you don't want to sign up on yet another web site, you can also contact me directly.) If you can't make tonight's meetup, I hope to see you at the DC PHP Conference later this week. Hope your week is off to a great start.
7 Points Of Contact In The World Of Online Marketing
Article/blog marketing - submitting articles and blog posts to authority sites in your industry that rank well (because they give you a link back plus human interest). Networking - building profiles and participating/sharing your links on sites like Ryze.com, Squidoo.com, LinkedIn.com, etc.