第一种用法：相当于as long as 只要，连接2个句子，从句是条件状语从句：
There had to be an answer — he was sure he could tease it out if only he had time.
If only it clears up,we’ll go.只要天一放晴，我们就去。
用来表达一个不可能实现的愿望或假设，句子多用虚拟语气，偶尔有时也用陈述语气：If only she would come!要是她能来就好了。
If only she come early.要是她早点来就好了。
If only I knew then what I know now.
If only she could marry me! 她要是能嫁给我就好了。
If only I were as clever as you.要是我像你一样聪明该有多好啊！
If only I could have helped put matters right.
If only I knew her name.
If only I were rich.
If only I could get some sleep, I would be able to cope.
She writes me often, if only to scold me because I haven't written to her 她常来信，即使仅仅为了责怪我还没回信给她。
If only it were that simple!
If only he could conceal his part in the accident
If only I could be master of this subject.
If only someone could help me!
If only he arrived in time.
Oh, if only he knew English!
If only we had arrived in time,we would,we would not have missed the train. 如果我们及时到达，我们就不会错过火车了。
If only he had been here.要是他当时在这儿就好了。
The pills might have helped him, if only he'd taken them regularly.
If only you had told me that some time ago
If only somebody had told us, we could have warned you.
If only I had another chance.要是我再有一次机会就好了。
Look at the trouble I am in! If only I had followed your advice.
If only my father had possessed an ounce of business sense
If only you hadn't felt compelled to meddle.
Oh! If only I'd known earlier.
If only it would stop raining.但愿雨快停下来。
If only he would hold her close to him.
If only the banks would lend money without limit!
If only it would clear up soon!
二、only if 表示：唯一的条件是，只有在……的条件下（的时候）才
Only if the red light comes on is there any danger to employees.
Children are admitted only if accompanied by an adult.
Syria will attend only if the negotiations deal with issues of substance.
The lawyer is paid only if he wins
Use a fire extinguisher only if you have been trained to do so ．
只有经过训练后才使用灭火器。高考真题- 2018 天津
So, everyone can have a good fortune only if he tries his best.
中考真题- 2018 衡阳
Where the penalties are not a must, they should be imposed only if the facts of a case support it.