Index: languages/pipp/src/common/php_string.pir
===================================================================
--- languages/pipp/src/common/php_string.pir	(revision 32467)
+++ languages/pipp/src/common/php_string.pir	(working copy)
@@ -123,7 +123,47 @@
 =cut
 
 .sub 'basename'
-    not_implemented()
+    .param pmc args :slurpy
+    .local string path
+    .local string suffix
+    .local string separator
+
+    ($I0, path, suffix) = parse_parameters('s|s', args :flat)
+    if $I0 goto L1
+    .RETURN_NULL()
+  L1:
+    sysinfo $S0, 4
+    if $S0 == 'MSWin32' goto L2
+    if $S0 == 'netware' goto L2
+    separator = '/'
+    goto L3
+  L2:
+    separator = '/\'
+  L3:
+    .local int len
+    .local int pos
+
+    $I1 = -1
+    len = length path
+    $P0 = split '', path
+  L4:
+    unless $P0 goto L5
+    $S1 = pop $P0
+    $I0 = index separator, $S1
+    inc $I1
+    if $I0 == -1 goto L4
+  L5:
+    pos = len - $I1
+    $S2 = substr path, pos
+
+    pos = index $S2, suffix
+    $S3 = substr $S2, pos
+    unless $S3 == suffix goto L6
+
+    $S3 = substr $S2, 0, pos
+    .RETURN_STRING($S3)
+  L6:
+    .RETURN_STRING($S2)
 .end
 
 =item C<string bin2hex(string data)>
