Employing a nonparametric approach of the principal component analysis (PCA), we forecast the future constraint on the equation of state $w(z)$ of dark energy, and on the effective Newton constant $mu(k,z)$, which parameterise the effect of modified gravity, using the planned SKA HI galaxy survey. Combining with the simulated data of Planck and Dark Energy Survey (DES), we find that SKA Phase 1 (SKA1) and SKA Phase 2 (SKA2) can well constrain $3$ and $5$ eigenmodes of $w(z)$ respectively. The errors of the best measured modes can be reduced to 0.04 and 0.023 for SKA1 and SKA2 respectively, making it possible to probe dark energy dynamics. On the other hand, SKA1 and SKA2 can constrain $7$ and $20$ eigenmodes of $mu(k,z)$ respectively within 10% sensitivity level. Furthermore, 2 and 7 modes can be constrained within sub percent level using SKA1 and SKA2 respectively. This is a significant improvement compared to the combined datasets without SKA.