How do you use a Matrix to toggle between multiple fields from multiple blocks?
Using switch is a good way to handle this, but it looks like your conditionals are just a little off:

{% for block in entry.contentBlock %}
    {% if block.type == 'text' %}
        {{ block.text }}
    {% elseif block.type == 'photo' %}
        {% set photo = block.photo.first() %}
        {% if photo %}
            &lt;img src="{{ photo.getUrl('thumb') }}" alt="{{ photo.title }}"&gt;
        {% endif %}
    {% endif %}
{% endfor %}


The same thing with the switch syntax would be:

{% for block in entry.contentBlock %}

    {% switch block.type %}
        {% case "text" %}
            {{ block.text }}
        {% case "photo" %}
            {% set photo = block.photo.first() %}
            {% if photo %}
                &lt;img src="{{ photo.getUrl('thumb') }}" alt="{{ photo.title }}"&gt;
            {% endif %}
    {% endswitch %}

{% endfor %}