If you're testing these examples on a fresh install of solr, you will need to run a commit statement after you add documents to receive results when searching.
For example, add this:
<?php $client->commit(); ?>
to example 3 to be able to get any results when doing a search using example 5.