MediaWiki uses Texvc to create png images from tex. see: http://www.mediawiki.org/wiki/Texvc
Texvc is an external program, so you have to start it via system() and save the result in a special folder. For example like this:
system('texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1 "rgb 1.0 1.0 1.0"')