I found out how to do a Many-To-Many, Bidirectional mapping with Doctrine in PHP.
Daily Archives: 2011-12-24 [Saturday]
PHP in_array and array_keys
The PHP function in_array is a really handy way to check if a value is in an array. Combine with array_keys to check if a value is in the array keys.
The importance of !important in CSS
I found an article on !important which explains how !important works in CSS.
PHP flush
Reading a character from a string
What do you do in PHP when you want to get the character at the specified index within the string? I’m not sure what the best way is, but the way that I’ve been using is with the substr function, passing in the index and a length of one.
Trying out PHP features
I’ve added a web testing section to my jj5-test project, and its hosted on Member Net in the test directory.
Now when I want to write little things that test/demo PHP features that I’m learning about I have a place to put the code.
Testing slib ‘scriptify’ and friends
I’ve written a few little functions to help me sanitise content before including it in automatically generated JavaScript. The idea is to prevent code injection.
You can see the tests for my function in the scriptify_test.php file on ProgClub Member Net (where jsphp.co is hosted). You can view the scriptify unit tests in pcrepo.
Unit testing is fun! :)
Strings in PHP
I’ve been looking into how strings work in PHP. Basically if you use a single quote the string is literal and the only two quotes accepted are \\ for backslash and \’ for single quote.
If you use double quotes on the other hand then backslash is the quote character so you can do things like \n for new line or \t for tab. Also you can use variable names in double quotes strings. I still don’t totally understand things like magic quotes work though.
Regular Expressions (Perl-Compatible)
I found the documentation for regular expressions at php.net.
I read somewhere on the internet to use the pattern modifiers “msU” to match multiline content, but while I understand the ‘m’ and the ‘s’ I don’t understand the ‘U’ very well. I’m not sure what it means to be greedy or ungreedy exactly. But I’ve been using msU pattern modifiers in my regexps that parse the phpjs.org content for import into jsphp.co.
Missing functions on phpjs.org
I found the documentation on missing functions at phpjs.org. I wrote some code to import these functions too, and now I’m modelling “port status” on functions at jsphp.co, where the port status can be any of: Ported, Unported, Not porting, Experimental or Workbench.