You can't do this directly with PHP.
A responsive site is not just responsive based on the size of the browser window, it also responds dynamically based on changes to the size of browser window while the page is visible.
The classic example of this is if a tablet user turns his device from portrait to landscape orientation; a responsive site will automatically adjust as he does so. But the same effect would be used for a normal desktop user simply resizing his browser window using the mouse.
This is not something that can be done with PHP because the page does not reload when this is done. PHP only serves the inital content, so any dynamic resizing needs to be done entirely by the browser.
CSS Media queries are the main tool for this, which tell the browser to use different CSS styles according to the page size. You would use this for example to set the widths of your page elements dynamically. You can also use media queries to set certain elements to be displayed or hidden according to the page size; for example, on a wide page layout, you could show the bigger text box, and on a smaller layout, only show the box containing the reduced text -- any CSS code can be included in a media query.
Find out more about media queries and how to use them here: http://css-tricks.com/css-media-queries/
Note that media queries are not supported by old browsers like IE8, so if you use them, it is a good idea to set sensible default values.
Alternatively, simple percentage based sizing can also work in many cases, and you may not even need media queries.
CSS can also do your ...
effect without any intervention from PHP:
text-overflow: ellipsis;
This style adds a ...
to the end of any text that is truncated because its box is too small and the content is hidden.
In order for the ellipsis to work, you also need to specify overflow:hidden
and white-space: nowrap
.
Hope that helps.